Home  >  Article  >  Backend Development  >  Use PHP's built-in multi-byte processing function to process Chinese, the best way_PHP tutorial

Use PHP's built-in multi-byte processing function to process Chinese, the best way_PHP tutorial

WBOY
WBOYOriginal
2016-07-20 10:59:29950browse

echo "

____________________

";
$string="242432 The sense of opposition is 456, and the fault is widespread in the embassy area 7890abc";
$mb_strlen=mb_strlen($string);
$len=20;
echo $string."

";
echo "The total length is: ".($mb_strlen+1)."

";
echo "Number of interceptions: ".$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)."
";
}
?>
See PHP’s Multi-Byte String Functions,
(1) Use --enable-mbstring=cn
when compiling (2) Modify /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!


www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/445600.htmlTechArticleecho ____________________ ; $string=242432The objection is 456, and it can be blamed on the embassy area 7890abc; $mb_strlen=mb_strlen ($string); $len=20; echo $string. ; The total length of echo is: .($m...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn