From 6e5a65ecb168459aef4550db85fba763016590c7 Mon Sep 17 00:00:00 2001 From: "johnny@pittpc.com" Date: Fri, 25 Sep 2020 17:16:02 -0400 Subject: [PATCH] Added PHP Truncate Function to functions.php --- functions.php | 11 +++++++++++ 1 file changed, 11 insertions(+) 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