diff --git a/functions.php b/functions.php index a209aef8..d0f2aada 100644 --- a/functions.php +++ b/functions.php @@ -172,4 +172,15 @@ function get_device(){ } } +function truncate($text, $chars = 25) { + if (strlen($text) <= $chars) { + return $text; + } + $text = $text." "; + $text = substr($text,0,$chars); + $text = substr($text,0,strrpos($text,' ')); + $text = $text."..."; + return $text; +} + ?> \ No newline at end of file