$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 "存在します" }