Home >Backend Development >PHP Tutorial >How to intercept Chinese and English strings in php_PHP tutorial
Many friends have been worrying about how to intercept Chinese and English strings in php (as the current mainstream development language) . I have been using this method. You may wish to give it a try.
function str_cut($str_cut,$length){
if(strlen($str_cut) > $length){ //Process the title, if it is too long, use...
for ($i=0; $i < $length; $i++){
$str_cut,0,$i);
}
return $str_cut;
}
$content="Hard electric plus fgfgfh workers build streets jhkjlk square carry big;l ;l a hard law fdfd country igkdjgkfdg…………………………”;
$content=str_cut($content,$length="25");
echo $ content;
http://www.bkjia.com/PHPjc/508668.html