php代码:--------------------------------------------------------------------------------
<?php
/**
***@author:lad
***@url :<a href="http://www.cnpik.com/" target="_blank">http://www.cnpik.com/</a>
***@e_mail:lianxiwoo@sohu.com
***@随便用,不收钱 :-)
*/
function cnsubstr($string,$sublen)
{
if($sublen>=strlen($string))
{
return $string;
}
$s="";
for($i=0;$i<$sublen;$i++)
{
if(ord($string{$i})>127)
{
$s.=$string{$i}.$string{++$i};
continue;
}else{
$s.=$string{$i};
continue;
}
}
return $s;
}// end function cnsubstr($string,$sublen)
/////////// use like this :
echo "<p>__________________________<p>";
$string="242432反对感是456犯得上广泛大使馆地方7890";
$sublen=strlen($string);
$len=20;
echo $string."<p>";
echo "总长为:".($sublen+1)."<p>";
echo "截取数:".$len."<p>";
for($i=1;$i<=$sublen+1;$i++){
if($i>$len){
echo $i."<b> →</b> ".cnsubstr($string,$i)."…<br>";
continue;
}
echo $i."<b> →</b> ".cnsubstr($string,$i)."<br>";
}
?>
Java Asp PHP .Net XML C/C++ CGI VB Jsp J2ee J2se J2me EJB Servlet Tomcat Resin Struts Weblogic Eclipse ANT GUI JMS Web servise IDEA Webphere Hibernate Spring Jboss Applet Swing Socket Javamail Perl Ajax P2P 安全 模式 框架 测试 开源 游戏
Windows XP Windows 2000 Windows 2003 Windows Me Windows 9.x Linux UNIX 注册表 操作系统 服务器 应用服务器