Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Limit string length
- // strip tags to avoid breaking any html
- $string = strip_tags($term->description);
- if (strlen($string) > 204) {
- // truncate string
- $stringCut = substr($string, 0, 204);
- $endPoint = strrpos($stringCut, ' ');
- //if the string doesn't contain any space then it will cut without word basis.
- $string = $endPoint? substr($stringCut, 0, $endPoint):substr($stringCut, 0);
- $string .= '...';
- }
- echo $string;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement