note 109211 deleted from function.in-array by danbrown
| From: | danbrown@php.net | Date: | Wed, 27 Jun 2012 16:36:31 +0000 |
| Subject: | note 109211 deleted from function.in-array by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-188930@lists.php.net to get a copy of this message | ||
Note Submitter: bronhy
----
@kitchin
The provided function in_arrayr does not work since it brakes out with return false after the first
recursive search
I have added a few lines of code and this one works
function inArrayr($needle, $haystack)
{
foreach ($haystack as $value)
{
if ($needle == $value)
{
return true;
}
elseif (is_array($value))
{
if(inArrayr($needle, $value))
return true;
}
}
return false;
}