note 57348 deleted from function.in-array by mazzanet

From: Date: Sat, 01 Oct 2005 05:09:52 +0000
Subject: note 57348 deleted from function.in-array by mazzanet
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-96110@lists.php.net to get a copy of this message
Note Submitter: tyron at x-plosive dot net ---- It seems that in_array() always returns TRUE if you are looking for the number 0, no matter whether it's in the array or not. Example: <?php $arr = array ("mom", "dad", 2, 8); if (in_array(0, $arr)) echo "found it"; ?> This will indeed output "found it". This does not occur with the needle being FALSE or "0" or any other integer I tested and it does not occur with an empty array. array_search(0, $arr) leads to a similar result: It will always return the number 0 (not FALSE). I'm not sure whether this is a bug or whether I'm just not getting a deeper meaning here.

« previous php.notes (#96110) next »