php排除字符串里包含某字符
$a = "'你好.你好','你好啊ct','他好','他好啊','我好','我好啊'";
$a = "'你好.你好','你好啊ct','他好','他好啊','我好','我好啊'";
$b=explode(',',$a);
$c = array(".", "ct");
foreach($b as $value){
foreach($c as $v){
if(strpos($value,$v) !==false){
$ar[]=$value;
break;
}
}
}
$result = array_diff($b, $ar);
echo join(',',$result);
$a = "'你好.你好','你好啊ct','他好','他好啊','我好','我好啊'";
$b=explode(',',$a);
$c = array(".", "ct");
foreach($c as $v){
$p="/" .preg_quote($v) ."/";
$ar[]=array_values(preg_grep($p,$b));
}
foreach($ar as $v) $arr[]=$v[0];
$result=array_diff($b,$arr);
echo join(',',$result);