PHP 제목(긴글) 줄이기

<?

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('글전체','최대길이');

?>

답글 남기기

이메일 주소는 공개되지 않습니다. 필수 필드는 *로 표시됩니다