PHP code :? Php/***** @ Author: glad *** @ URL: ahrefhttp: // feature-) */functioncnSubStr ($ s PHP code:
/**
* ** @ Author: Glad
* ** @ URL: http://www.cnpik.com/
* ** @ E_mail: lianxiwoo@sohu.com
* ** @ Use it as needed. do not collect the money :-)
*/
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"__________________________
";
$ String = "242432 objection: 456 the attack against a wide range of embassy places 7890 ";
$ Sublen = strlen ($ string );
$ Len = 20;
Echo $ string ."
";
Echo "Total length:". ($ sublen + 1 )."
";
Echo "number of interceptions:". $ len ."
";
for($i=1;$i<=$sublen+1;$i++){
if($i>$len){
echo $i." → ".cnSubStr($string,$i)."…
";
continue;
}
echo $i." → ".cnSubStr($string,$i)."
";
}
?>