note 72191 deleted from function.array-search by nlopess

From: Date: Sun, 07 Jan 2007 14:09:00 +0000
Subject: note 72191 deleted from function.array-search by nlopess
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-121380@lists.php.net to get a copy of this message
Note Submitter: Reason: useless ---- Useful example: <?php $my_array = array(0 =>"air", 1 => "water", 2=> "soil"); if(array_search('air', $my_array)) echo ' "air" is in $my_array'; else echo ' "air" is NOT in $my_array'; //it echoes: "air" is NOT in $my_array ?> The array_search function returns an index (or a key). If the index of the matched element is 0, then you can't use this function in an if or while structure, because bool(0) == false.

« previous php.notes (#121380) next »