cut string

Posted at 2006/03/15 22:43 // in 웹프로그래밍™/PHP, ASP // by 블루비
<?
function cutstr($str,$max)
{
$count = strlen($str);

if($count >= $max)
{
for ($pos=$max;$pos>0 && ord($str[$pos-1])>=127;$pos--);

if (($max-$pos)%2 == 0)
$str = substr($str, 0, $max) . "...";
else
$str = substr($str, 0, $max+1) . "...";
return $str;
}
else
{
$str = "$str";
return $str;
}
}
?>
2006/03/15 22:43 2006/03/15 22:43

http://blueb.net/blog/trackback/361

댓글을 남겨주세요.

[로그인][오픈아이디란?]