php过滤字符串内容的
下面举了二个实现来告诉你如何过滤重复的内容,有需要的朋友可以参考
foreach($arr as $value){ if(!empty($value)){ $strs=strstr($value,"新闻"); } }
输出:新闻 新闻
直接用array_unique 函数就可以了。
$string= '数组aabbccdd'; function str_split_utf8($str) { $split=1; $array = array(); for ( $i=0; $i < strlen( $str ); ){ $value = ord($str[$i]); if($value > 127){ if($value >= 192 && $value <= 223) $split=2; elseif($value >= 224 && $value <= 239) $split=3; elseif($value >= 240 && $value <= 247) $split=4; }else{ $split=1; } $key = NULL; for ( $j = 0; $j < $split; $j++, $i++ ) { $key .= $str[$i]; } array_push( $array, $key ); } return $array; } print_r(array_unique(str_split_utf8($string)));
这里有篇参考文章
http://www.phprm.com/phper/21/899e11a21ae817a97d3ce64f851ab9f6.htm
本文地址:http://www.phprm.com/develop/39932.html
转载随意,但请附上文章地址:-)