note 80390 deleted from function.array-search by nlopess

From: Date: Fri, 25 Jan 2008 12:17:33 +0000
Subject: note 80390 deleted from function.array-search by nlopess
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-135401@lists.php.net to get a copy of this message
Note Submitter: lancelot--du-lac at hotmail dot fr ---- If you want my humble opinion, it's really too bad that array_search returns the key at which it has found the needle in haystack. I've just spent an hour figuring out WHY my test with my array would always fail with the first element of the array. I had some code like: if (array_exists($myarray)) {...} It took me a while figuring out why nothing ever happened to the first element that I had defined. Now I get it: the first element I have defined is $myarray[0]! Zero!.. My life would have been easier tonight if the function simply returned TRUE when it does find the needle. It's really too bad... and funny at the same time, so I just thought I'd share. Changing my code to "if (array_exists($myarray) !== FALSE) {...}" should work. I'll just try it now.

« previous php.notes (#135401) next »