arrays - PHP array_search -
is there function accomplish equivalent of array_search $needle array? like, ideal solution:
$needle = array('first', 'second'); $haystack = array('fifth','second','third', 'first'); // returns key 1 in haystack $search = array_search( $needle, $haystack ); if no function, other functions accept needles may arrays can use create custom function?
this might build function:
$intersection = array_intersect($needle, $haystack); if ($intersection) // $haystack has @ least 1 of $needle if (count($intersection) == count($needle)) // $haystack has every needle
Comments
Post a Comment