note 21666 deleted from function.array-search by felipe
| From: | felipe@php.net | Date: | Sun, 10 Feb 2008 13:11:51 +0000 |
| Subject: | note 21666 deleted from function.array-search by felipe | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-135969@lists.php.net to get a copy of this message | ||
Note Submitter: phil at limbrey dot net
----
The function posted by 'chen.avinadav@vbulletin.com' on '13-Apr-2002 04:15' is
wrong!
You are matching the value not the key. It should read:
<?php
function array_search($needle, $haystack) {
$match = false;
foreach ($haystack as $key => $value) {
if ($value == $needle) {
$match = $key;
}
}
return $match;
}
?>