note 84602 modified in function.in-array by danbrown
| From: | danbrown@php.net | Date: | Mon, 21 Jul 2008 16:09:54 +0000 |
| Subject: | note 84602 modified in function.in-array by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-142423@lists.php.net to get a copy of this message | ||
Recursive in array using SPL
<?php
function in_array_recursive($needle, $haystack) {
$it = new RecursiveIteratorIterator(new RecursiveArrayIterator($haystack));
foreach($it AS $element) {
if($element == $needle) {
return true;
}
}
return false;
}
?>
--was--
Recursive in array using SPL
function in_array_recursive($needle, $haystack) {
$it = new RecursiveIteratorIterator(new RecursiveArrayIterator($haystack));
foreach($it AS $element) {
if($element == $needle) {
return true;
}
}
return false;
}
http://php.net/manual/en/function.in-array.php