PHP Salt


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

Version: 2.31.2
Last Build: July 26, 2022 10:10am (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