echo "
__________________________
";
$string="242432反對感是456,,犯得上廣泛大使館地方7890abc";
$mb_strlen=mb_strlen($string);
$len=20;
echo $string."
";
echo "總長為:".($mb_strlen+1)."
";
echo "截取數:".$len."
";
for($i=1;$i<=$mb_strlen+1;$i++){
if($i>$len){
echo $i." → ".mb_substr($string,$i)."…
";
continue;
}
echo $i." → ".mb_substr($string,$i)."
";
}
?>
參看PHP的Multi-Byte String Functions,
(1)編譯時使用--enable-mbstring=cn
(2)修改/usr/local/lib/php.inc
default_charset = "zh-cn"
mbstring.language = zh-cn
mbstring.internal_encoding =zh-cn
Everthing I do, I do it for you!
My linux!