PHP截取中文_PHP教程

WBOY
發布: 2016-07-13 17:45:10
原創
823 人瀏覽過

function SubTitle($String,$Length) {
 if (mb_strwidth($String, 'UTF8')   return $String;
 }else{
  $I = 0;
  $len_word = 0;
  while ($len_word    $StringTMP = substr($String,$I,1);
   if ( ord($StringTMP) >=224 ){
    $StringTMP = substr($String,$I,3);
    $I = $I + 3;
    $len_word = $len_word + 2;
   }elseif( ord($StringTMP) >=192 ){
    $StringTMP = substr($String,$I,2);
    $I = $I + 2;
    $len_word = $len_word + 2;
   }else{
    $I = $I + 1;
    $len_word = $len_word + 1;
   }
   $StringLast[] = $StringTMP;
  }
  /* raywang edit it for dirk for (es/index.php)*/
  if (is_array($StringLast) && !empty($StringLast)){
   $StringLast = implode("",$StringLast);
   $StringLast .= "...";
  }
  return $StringLast;
 }
}

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/478688.htmlTechArticlefunction SubTitle($String,$Length) { if (mb_strwidth($String, UTF8) = $Length ){ return $String; }else{ $I = 0; $len_word = 0; while ($len_word $Length){ $StringTMP = substr($Strin...
來源:php.cn
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!