I have the next code:
$string = "hello to all world";
$strings_compare = tomorrow, hello, world;
$string_arrays =split(',',$strings_compare);
for ($i=0; $i<count($string_arrays); $i++){
$resultado = preg_match("/$string_arrays[$i]/",$string);
if($resultado == false){
echo "no match";
}else {
echo "match";
}
}
in this code the results are:
no match, match, no match
and the results should be: no match, match and match. What is my error?
if I change the $string by $string='say hello to all world now'
the results are match, match, match, this is OK.
It works fine for me when I’m using valid array syntax.
Returns