您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

php 字符截取函数

2024/2/26 8:13:19发布22次查看
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;
}
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product