PHP function any_in_array - tests if any of $needles are in $haystack
Just a quick post. You might find this useful. It compares one array ($needles) against another ($haystack) and returns true if any element of $needles is present in $haystack
/** * alternative in_array(). Tests if one or more of $needle are in $haystack * * e.g. * echo any_in_array(array("a", "x", "z"), array("a", "b", "c")); * returns true ("a" is in $haystack) * * @param $needles array things to search for * @param $haystack array thing to search in * * @return true if any of $needles in $haystack */ function any_in_array($needles = array(), $haystack = array()) { foreach($needles as $needle) { if (in_array($needle, $haystack)) { return true; } } return false; }
- Richard@Home:


Comments
Post new comment