note 85421 deleted from function.in-array by danbrown
| From: | danbrown@php.net | Date: | Mon, 08 Jun 2009 21:39:30 +0000 |
| Subject: | note 85421 deleted from function.in-array by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-156494@lists.php.net to get a copy of this message | ||
Note Submitter: com (dot) gmail (at) deceze
----
Maybe the most efficient recursive in_array variation yet? ;)
<?php
function recursive_in_array($needle, $haystack) {
foreach ($haystack as $stalk) {
if ($needle == $stalk || (is_array($stalk) && recursive_in_array($needle, $stalk))) {
return true;
}
}
return false;
}
?>