note 24082 deleted from function.in-array by felipe
| From: | felipe@php.net | Date: | Sun, 30 Dec 2007 18:47:57 +0000 |
| Subject: | note 24082 deleted from function.in-array by felipe | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-134465@lists.php.net to get a copy of this message | ||
Note Submitter: robe_NO_SPAM at post_NO_SPAM dot cz
----
In contribution of <jon@gaarsmand.dk>:
I think we should use more general approach while walking through array, so instead your
'for' loop I'd suggest while list.. as follows:
function in_multi_array($needle, $haystack) //taken from php.net, adapted
{
$in_multi_array = false;
if(in_array($needle,
$haystack))
{
$in_multi_array = true;
}
else
{
while (list($tmpkey,$tmpval) = each ($haystack))
//here is the change
{
if(is_array($haystack[$tmpkey])){
if (in_multi_array($needle, $haystack[$tmpkey]))
{
$in_multi_array = true;
break;
}
}
}
}
return $in_multi_array;
}
I hope code is readible, some problems with formatting occured.