mirror of
https://github.com/itflow-org/itflow
synced 2026-02-28 02:44:53 +00:00
Added PHP Truncate Function to functions.php
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user