1. 程式人生 > >php過濾字串中重複的字元(包含中文)

php過濾字串中重複的字元(包含中文)

<?php
header('Content-Type:text/html; Charset=utf-8');
function mb_str_split( $string ) {
    return implode('', array_unique(preg_split('/(?<!^)(?!$)/u', $string ))); 
} 

$string   = '過過過過過ggggg年年年nnnnnn啦啦啦啦啦啦lllll'; 
$charlist = mb_str_split( $string ); 


echo $charlist;