note 101001 deleted from function.in-array by danbrown
| From: | danbrown@php.net | Date: | Fri, 19 Nov 2010 14:22:52 +0000 |
| Subject: | note 101001 deleted from function.in-array by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-174192@lists.php.net to get a copy of this message | ||
Note Submitter: Andy B
----
bogdan AT bogdanconstantinescu DOT com example of searching in a multidimensional array works as
long as you don't set the Array keys yourself.
If you need to search a multidimensional array where you have used text keys then try this -
function in_marray($elem, $array)
{
foreach($array as $key=>$value)
{
if($value === $elem)
{ return true; }
else
{
if(is_array($value))
{
if(in_marray($elem, ($value)))
{ return true; }
}
}
}
return false;
}