方法一:
复制代码 代码如下:
$text = '数组aabbccdd';
$text_filter = '';
$filter = array();
$len = mb_strlen($text, 'utf-8');
for ($i = 0; $i$char = mb_substr($text, $i, 1, 'utf-8');
if (!isset($filter[$char])) {
$text_filter .= $char;
$filter[$char] = $char;
}
}
echo $text_filter;
复制代码 代码如下:
$string= '数组aabbccdd';
function str_split_utf8($str) {
$split=1;
$array = array();
for ( $i=0; $i $value = ord($str[$i]);
if($value > 127){
if($value >= 192 && $value $split=2;
elseif($value >= 224 && $value $split=3;
elseif($value >= 240 && $value $split=4;
}else{
$split=1;
}
$key = NULL;
for ( $j = 0; $j $key .= $str[$i];
}
array_push( $array, $key );
}
return $array;
}
print_r(array_unique(str_split_utf8($string)));
以上就介绍了pretty rhythm dear my future php去除重复字的实现代码,包括了pretty rhythm dear my future方面的内容,希望对PHP教程有兴趣的朋友有所帮助。
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号