Skip to content

Instantly share code, notes, and snippets.

@jeonghwan-kim
Created October 12, 2013 10:24
Show Gist options
  • Select an option

  • Save jeonghwan-kim/6948397 to your computer and use it in GitHub Desktop.

Select an option

Save jeonghwan-kim/6948397 to your computer and use it in GitHub Desktop.
한글 문자열 자르기 $text: 자를 문자열 $count: 잘라서 반환할 텍스트 길이 $more: 반환할 텍스트 마직막에 붙일 길고
function cut_text($text, $count, $more = "...") {
$length = mb_strlen($text, "UTF-8");
if($length <= $count)
return $text;
else
return mb_substr($text, 0, $count, "UTF-8") . " " . $more;
}
echo cut_text('우리 나라 만세', 10);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment