Re: Question about array_search

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, 11 Oct 2004 09:07:13 -0700, Brian Dunning
<brian@xxxxxxxxxxxxxxxx> wrote:

> The problem is that if the item is at index 0 in the array, array_search gives the 
> same answer as if it's not in there at all. 

No it doesn't.

If it's in index 0 it returns 0, if it's not there at all it returns FALSE.

you need to use something like:

   if (array_search($needle, $haystack) === false) {
     // add $needle to $haystack
   }

http://lv.php.net/array-search
http://php.net/manual/en/language.operators.comparison.php

  -robin

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux