// A function in php that controls string output (Chinese and English). How many words are displayed in each line to avoid the influence of English
// $str String
// $len The number of words displayed in each line (Chinese characters × 2)
function rep($str,$len)
{
$strlen=strlen($str);
$i=0;
$finstr="";
$pos=0;
while($i<$strlen)
{
$s1=substr($str,$i,1);
$s2=ord($s1);
if($s2>0xa0){
$finstr.=substr($str,$i,2);
$pos+=2 ;
$i+=2;
}else{
switch($s2){
case 13:
$fin str.="
";
break; break;
case 32;
$finstr.=" ";
$pos++; chars($s1);
$pos++;
break;
$i++ ;
} //if
if($pos>=$len){
$finstr.="
";
$pos=0;
}
} //while
return $finstr;
}
http://www.bkjia.com/PHPjc/316636.html
www.bkjia.com
true
http: //www.bkjia.com/PHPjc/316636.html