|
 |
14³â Àü |
/*
¹®ÀÚ¿ ÀÚ¸£±â
°á°ú=cut(¹®ÀÚ¿,±æÀÌ);
*/
function cut($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;
}
}
Á¤±Ô½ÄÀ» ÀÌ¿ëÇÑ ¹®ÀÚÀÚ¸£±â
function str_cutting($str, $len){
//¸ÕÀú ¹«Á¶°Ç ÀÚ¸£°í
//ÇѱÛÀÌ ¾Æ´Ñ°Ç ÇѱÛÀÚ¾¿ ¼¼°í ´Ù¸¥°Ç µÎ±ÛÀÚ¾¿ ¼¾´Ù
preg_match('/([x00-x7e]|..)*/', substr($str, 0, $len), $rtn);
//¿ø·¡ ±Û ±æÀÌ°¡ ±æ¸é Á¡Á¡Á¡À» ºÙ¿©ÁØ´Ù(ÀÌ ¾Æ·§ÁÙÀº ¼±ÅÃ)
if ( $len < strlen($str) ) $rtn[0].="...";
return $rtn[0];
}
str_cutting("¿øÇϴ¹®ÀÚ¿",±æÀÌ);
|
|
̵̧ : 331 |
̵̧
¸ñ·Ï
|
|