I searched the PHP manual for a while and cannot find any command that does what I want.
I have an array with keys and values, for example:
$Fields = array("Color"=>"Bl","Taste"=>"Good","Height"=>"Tall");
Then I have a line, for example:
$Headline = "My black coffee is cold";
Now I want to find out if any of the array values ($ Fields) somewhere in the string ($ Headline).
Example:
Array_function_xxx($Headline,$Fields);
Gives the result true because "bl" is in the $ Headline line (as part of "Black").
I ask because I need performance ... If this is not possible, I will just make my own function ...
EDIT . I am looking for something like stristr (string $ haystack, array $ needle);
thank
SOLUTION . I came up with its function.
function array_in_str($fString, $fArray) {
$rMatch = array();
foreach($fArray as $Value) {
$Pos = stripos($fString,$Value);
if($Pos !== false)
$rMatch[] = array( "Start"=>$Pos,
"End"=>$Pos+strlen($Value)-1,
"Value"=>$Value
);
}
return $rMatch;
}
, .