note 37449 added to function.in-array
| From: | duerra at nospam dot yahoo dot com | Date: | Sat, 15 Nov 2003 18:01:21 +0000 |
| Subject: | note 37449 added to function.in-array | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-60426@lists.php.net to get a copy of this message | ||
I was having frustrations with getting associative arrays to work with in_array, or any of the
previous suggestions posted by users here, so I created my own version of in_array to search a given
key in an associative array for a particular value:
function in_multi_assoc_array($search, $array, $key)
{
foreach($array AS $tmpkey=>$tmpvalue)
{
if($tmpkey == $key)
{
if($tmpvalue == $tmpvalue)
{
return true;
}
}
if(is_array($value))
{
in_multi_assoc_array($search, $value, $key);
}
}
return false;
}
----
Manual Page -- http://www.php.net/manual/en/function.in-array.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+37449
Delete -- http://master.php.net/manage/user-notes.php?action=delete+37449&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+37449&report=yes
Search -- http://master.php.net/manage/user-notes.php