note 31415 modified in function.array-search by vrana
| From: | vrana@php.net | Date: | Tue, 17 Aug 2004 14:49:06 +0000 |
| Subject: | note 31415 modified in function.array-search by vrana | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-79858@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:
<?php
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
--was--
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://php.net/manual/en/function.array-search.php