note 38645 modified in function.array-search by kennyt
| From: | kennyt@php.net | Date: | Thu, 01 Jan 2004 06:55:04 +0000 |
| Subject: | note 38645 modified in function.array-search by kennyt | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-62737@lists.php.net to get a copy of this message | ||
[Notes that argument order in examples is reversed; has been fixed.]
--was--
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.
http://www.php.net/manual/en/function.array-search.php