Maison > Article > développement back-end > 如何判断包含某个中文字?
$str=array("西瓜","苹果","香蕉")$str_long="西瓜很大颗";
哪个判断哪个?
$str_long句子里有没有包含阵列里面的字
$arr=array("西瓜","苹果","香蕉");$str_long="西瓜很大颗";foreach($arr as $k=>$v){ if(strpos($str_long,$v)!==false){ $exists[]=$v; }}echo "<pre class="brush:php;toolbar:false">";print_r($exists);echo "";/*Array( [0] => 西瓜)*/
$str=array("西瓜","苹果","香蕉");$str_long="西瓜很大颗";if(strlen($str_long) != strlen(str_replace($str, '', $str_long))) { echo '存在';}
$count = 0;
str_replace($str, '', $str_long, $count);
if( $count > 0 ){
//echo "存在";
}