note 93045 deleted from function.in-array by mazzanet
| From: | mazzanet@php.net | Date: | Thu, 20 Aug 2009 14:28:47 +0000 |
| Subject: | note 93045 deleted from function.in-array by mazzanet | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-159704@lists.php.net to get a copy of this message | ||
Note Submitter: fabien dot menager at gmail dot com
----
<?php
/**
* Checks recursively if a value exists in an array
* @return Returns TRUE if needle is found in the array, FALSE otherwise.
* @param mixed $needle The searched value.
* @param array $haystack The array.
* @param bool $strict If the third parameter strict is set to TRUE then the in_array_recursive()
function will also check the types of the needle in the haystack.
*/
function in_array_recursive($needle, $haystack, $strict = false) {
if (in_array($needle, $haystack, $strict)) return true;
foreach ($haystack as $v) {
if (is_array($v) && in_array_recursive($needle, $v, $strict)) return true;
}
return false;
}
?>