PHP Salt


A little dash of PHP... my collection of php functions

Version: 2.33.2
Last Build: December 29, 2023 20:28pm (PST)

Main Menu

Home

Get PHP Salt


The Functions

array
db
file
graph
html
mail
math
misc
mobile
script
string
system
time
web
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:


See Also

And a shot out to:

PHP - php.net
Fedora Server - getfedora.com
Shameless ads to pay for site