php 字符截取函数
[PHP房产程序|BBWPS]功能介绍 1、5种信息类别发布:出租、求租、出售、求购、楼盘信息,支持会员发布信息审核; 2、灵活的信息参数设置; 3、充足的信息字段; 4、简单易用的发布/编辑功能,支持配图上传; 5、灵活的信息管理功能; 6、信息输出伪静态,方便搜索引擎抓取数据; 7、支持RSS输出; 8、内置数据高速缓冲技术,可灵活设置缓冲功能是否启动及过期时间; 9、支持 Google 地图
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;
}










