note 72191 added to function.array-search
| From: | php-general at lists dot php dot net | Date: | Sun, 07 Jan 2007 02:47:50 +0000 |
| Subject: | note 72191 added to function.array-search | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-121370@lists.php.net to get a copy of this message | ||
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.
----
Server IP: 195.70.37.52
Probable Submitter: 62.68.175.126
----
Manual Page -- http://www.php.net/manual/en/function.array-search.php
Edit -- https://master.php.net/note/edit/72191
Del: integrated -- https://master.php.net/note/delete/72191/integrated
Del: useless -- https://master.php.net/note/delete/72191/useless
Del: bad code -- https://master.php.net/note/delete/72191/bad+code
Del: spam -- https://master.php.net/note/delete/72191/spam
Del: non-english -- https://master.php.net/note/delete/72191/non-english
Del: in docs -- https://master.php.net/note/delete/72191/in+docs
Del: other reasons-- https://master.php.net/note/delete/72191
Reject -- https://master.php.net/note/reject/72191
Search -- https://master.php.net/manage/user-notes.php