检查字符串中是否存在数组中的任何字符

时间:2016-06-06 09:59:25

标签: php character

我想检查$array中是否存在$string中的任何字符:

$array = array('â','à','á','ê','ô');
$string = 'hello every body';

1 个答案:

答案 0 :(得分:0)

$found = false;
foreach ($array as $char){
    //you can use strpos [without 'i'] for case-sensitive comparison
    if (stripos($char,$string) !== false){ 
        $found=true;
        break;
    }
}