Re: Question about array_search

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

 



Brian Dunning wrote:

Say I'm trying to add a value to an array, only if it's not already in there somewhere; so I do an array_search to see. 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 the value is not there, it returns FALSE. If it's at index zero, then it returns zero.


if($a === FALSE)
{ echo 'a is false'; }
elseif($a === 0)
{ echo 'a is zero'; }

Read here for an explanation of the above: http://us2.php.net/manual/en/language.operators.comparison.php

--

---John Holmes...

Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/

php|architect: The Magazine for PHP Professionals – www.phparch.com

--
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