note 38645 added to function.array-search
| From: | AndrewRoseagr at parrswood dot net | Date: | Wed, 31 Dec 2003 19:27:08 +0000 |
| Subject: | note 38645 added to function.array-search | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-62730@lists.php.net to get a copy of this message | ||
I dont know if anyone else has noticed this, or maybe Ive missed something.. but the example seems
to be wrong, well is wrong, shouldnt it be:
<?php
$array = array(0 => "blue", 1 => "red", 2 => "green", 3 =>
"red");
$key = array_search("green", $array); // $key = 2;
$key array_search("red", $array); // $key = 1;
?>
Notice we are now actualy searching for the needle in the haystack instead of searching for the
haystack in the needle as the original example was doing.
NOTE to moderator, if I am right you wont need to add this note, just change the example and make a
small note to bring attention to the problem so others who have slipped up on this will know it was
the example that was wrong.
cheers.
----
Manual Page -- http://www.php.net/manual/en/function.array-search.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+38645
Delete -- http://master.php.net/manage/user-notes.php?action=delete+38645&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+38645&report=yes
Search -- http://master.php.net/manage/user-notes.php