I have an array:
$myArray= array(
"Cold coffe",
"Cold water",
"Disco",
"I love you"
);
And i have string:
$string = "My baby I love you"
I wanted to check if one of this values exsits in this string and i do it in this way:
function match($needles, $haystack)
{
foreach($needles as $needle){
if (strpos($haystack, $needle) !== false) {
return true;
}
}
return false;
}
if(match($myArray, $string)){
echo "Matching.";
}
And this works ok, but i want to know which one of this values in $myArray exsits in this string and print that value, how i can do that?