psMatchAny() Returns true if any matches
Description:
pass it your main str and an array or comma string of items to check if any match
Usage:
$res = psMatchAny($str, $ary|$str);
Example:
$ary = array("Ferrari", "Lamborghini", "__exotics");
// search for ferrari if ( psMatchAny("Ferrari", $ary) == true ) { print "Ferrari"; }
// search for any exotics if ( psMatchAny("__exotics", "Ferrari, Lambo, __exotics") == true ) { print "Exotics"; }
Code:
function psMatchAny($str, $items) { $ary = psStrToAry($items, ","); $res = false; foreach ($ary as $n=>$val) { if ($str == $val) { $res = true; break; } } return $res; }
Changlelog:
|
|