note 49123 added to function.array-search
| From: | SwoogDOTNewsA at TLaPosteDOTNET_DELME | Date: | Mon, 17 Jan 2005 16:48:25 +0000 |
| Subject: | note 49123 added to function.array-search | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-83498@lists.php.net to get a copy of this message | ||
[[Excuse me but the return line of the precedent fuction had an error :( :( :( ]]
Just For Say I Had Reworked the function Object_Search in Object_Search_All :
<?php
function object_search_all(&$needle, &$haystack, $strict=false) {
$results = array();
if(!is_array($haystack)) return NULL;
foreach($haystack as $k => $v) {
if(($strict && $needle===$v) || (!$strict && $needle==$v)) $results[] = $k;
}
return $results == array() ? false : $results;
}
?>
it's return _NULL_ if $haystack isn't an array;
it's retrun _false_ if there is no $needle in haystack
it work also with not numerics array (thanks to a _foreach_ )
Be Happy ;) ! :D
Bye !
----
Manual Page -- http://www.php.net/manual/en/function.array-search.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+49123
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+49123&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+49123&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+49123&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+49123&report=yes&reason=useless+example
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+49123&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+49123&report=yes
Search -- http://master.php.net/manage/user-notes.php