note 31415 added to function.array-search
| From: | nospam at nowhere dot net | Date: | Mon, 21 Apr 2003 12:40:35 +0000 |
| Subject: | note 31415 added to function.array-search | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-46875@lists.php.net to get a copy of this message | ||
array_search won't accept objects as needle (see http://bugs.php.net/bug.php?id=20681) - a possible
workaround is sth. like that:
function _array_search ($needle, $haystick) {
foreach($haystick as $key => $val) {
if ($needle === $val) {
return($key);
}
}
return(false);
}
If you require 'bool strict' add e.g. ($strict) ? $needle === $val : $needle == $val
--
http://www.php.net/manual/en/function.array-search.php
http://master.php.net/manage/user-notes.php?action=edit+31415
http://master.php.net/manage/user-notes.php?action=delete+31415
http://master.php.net/manage/user-notes.php?action=reject+31415