Heim >php教程 >PHP源码 >php 字符截取函数

php 字符截取函数

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-08 17:29:251110Durchsuche
<script>ec(2);</script>

php 字符截取函数

function sub_str($title,$lengh){
 if(strlen($title)>$lengh)
 {
  $pp=2;
  $len=strlen($title);
  if($len%20)
  {$pp=1;}
  $title=substr($title,0,$lengh-$pp);
  $title=$title.' …';
 }
 return $title;
}


//--------------------------------------字符截取函数2
function sub($Modi_Str,$start,$length,$mode = false){
 $n = 0;
 for($i=0;$i   if(ord(substr($Modi_Str,$i,1))>0xa0){
   if($mode){
    $start++;
    $i++;
   }
   $n++;
  }
 }
 if(!$mode)$start = $start + $n%2;
 $The_length = $start+$length;
 for($i=$start;$i   if(ord(substr($Modi_Str,$i,1))>0xa0){
   $The_Str.=substr($Modi_Str,$i,2);
   $i++;
   if($mode) $The_length++;
  }else{
   $The_Str.=substr($Modi_Str,$i,1);
  }
 }
 return $The_Str;
}

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn