<?
function cut_str($TITLE, $COUNT)
{
if (strlen($TITLE) > $COUNT)
{
$i = 0;
$re = "";
do {
$ch = substr($TITLE, $i, 1);
if (ord($ch) > 127) {
$ch2 = substr($TITLE, $i+1, 1);
$re .= $ch . $ch2;
$i+=2;
} else {
$re .= $ch;
$i++;
}
} while($i<$COUNT);
return $re . "...";
} else
return $TITLE;
}
// 사용 예 ----------------------------------------------
$title = cut_str('글전체','최대길이');
?>