note 88919 deleted from function.in-array by danbrown
| From: | danbrown@php.net | Date: | Fri, 13 Feb 2009 14:01:53 +0000 |
| Subject: | note 88919 deleted from function.in-array by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-150620@lists.php.net to get a copy of this message | ||
Note Submitter: fabien dot menager at gmail dot com
----
Hello, I think this in_array_recursive is faster :
<?php
function in_array_recursive($needle, $haystack) {
if (in_array($needle, $haystack)) return true;
foreach ($haystack as $v) {
if (is_array($v) && in_array_recursive($needle, $v)) return true;
}
return false;
}
?>