note 102147 deleted from function.in-array by danbrown
| From: | danbrown@php.net | Date: | Sat, 29 Jan 2011 22:03:57 +0000 |
| Subject: | note 102147 deleted from function.in-array by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-176502@lists.php.net to get a copy of this message | ||
Note Submitter: Anonymous
----
Here is a function that returns true if the element is in a multi-array.
function in_multiarray($elem, $array){
foreach($array as $item){
if($item == $elem){
return true;
exit;
}elseif(is_array($item)){
if(in_multiarray($elem, $item)){
return true;
exit;
}
}
}
return false;
}
Tried the followings comments and it did not work:
cousinka at gmail dot com 09-Aug-2010 12:44
bogdan AT bogdanconstantinescu DOT com 21-Apr-2010 03:01