$lenth){ $ok=1;} $str = trim($str); $backcnt= 0; $cntcheck =0; if ($start>0 ){ if(ord($str[$start]) >= 128) { for ($i=$start;$i>0;$i--) { if (ord($str[$i]) >= 128){ $backcnt++; }else{ break; } } $start= ($backcnt%2) ? $start : $start-1; if (($backcnt%2)==1){ $cntcheck = 0; }else{ $cntcheck = 1; } } } $backcnt2= 0; for ($i=($len-1);$i>=0;$i--) { if (ord($str[$i+$start]) >= 128){ $backcnt2++; }else{ break; } } if (($backcnt2%2)==1){ $cntcheck2 = 1; }else{ $cntcheck2 = 0; } (int)$cnt=$len-abs($backcnt2%2); if(($cntcheck+$cntcheck2)==2) $cnt+=2; $cutstr = substr($str,$start,$cnt); if ($ok){$cutstr .= "...";} return $cutstr; } ?>
더보기