영원한사랑

<?
// 첫번째 방법
function strcut_utf8($str, $len, $tail='...'
) { 
   
$rtn
= array(); 
    return
preg_match('/.{'.$len.'}/su', $str, $rtn) ? $rtn[0].$tail : $str

}

// 두번째 방법
function resizeString($Str, $size, $addStr="..."
) { 
    if(
mb_strlen($Str, "UTF-8") > $size) return mb_substr($Str, 0, $size, "UTF-8").$addStr

    else return
$Str



echo
strcut_utf8("가나다라ㄳ마바사", "5")."<br>\n"
;
echo
resizeString("가나다라ㄳ마바사", "5"
);
?>