note 21666 added to function.array-search

From: Date: Wed, 22 May 2002 14:52:29 +0000
Subject: note 21666 added to function.array-search
Groups: php.notes 
Request: Send a blank email to php-notes+get-30906@lists.php.net to get a copy of this message
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: function array_search($needle, $haystack) { $match = false; foreach ($haystack as $key => $value) { if ($value == $needle) { $match = $key; } } return $match; } -- http://www.php.net/manual/en/function.array-search.php http://master.php.net/manage/user-notes.php?action=edit+21666 http://master.php.net/manage/user-notes.php?action=delete+21666 http://master.php.net/manage/user-notes.php?action=reject+21666

« previous php.notes (#30906) next »