次のコードがあります:
$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";
}
}
このコードでは、結果は次のようになります:一致なし、一致、一致なし
結果は次のようになります:一致なし、一致、一致。私のエラーは何ですか?
結果が一致、一致、一致$string
によって変更された場合、これはOKです。$string='say hello to all world now'