note 93652 modified in function.in-array by thiago
| From: | thiago@php.net | Date: | Mon, 21 Sep 2009 17:27:46 +0000 |
| Subject: | note 93652 modified in function.in-array by thiago | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-160897@lists.php.net to get a copy of this message | ||
Here's a function to see if all needles of an array are in a haystack:
<?php
function array_in_array($needles, $haystack) {
$matched_needles = 0;
foreach ($needles as $needle) {
if ( in_array($needle, $haystack) ) $matched_needles++;
}
return ($matched_needles == count($needles)) ? true : false;
}
?>
--was--
Here's a function to see if all needles of an array are in a haystack:
function array_in_array($needles, $haystack) {
$matched_needles = 0;
foreach ($needles as $needle) {
if ( in_array($needle, $haystack) ) $matched_needles++;
}
return ($matched_needles == count($needles)) ? true : false;
}
http://php.net/manual/en/function.in-array.php