Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace WPX\Utility;
- /**
- * Truncate
- *
- * A very simple function that limits a given block of text to the specified length.
- *
- * @since 1.0
- * @param string $text
- * @param string $limit
- * @param string $break The character to break on (typically a space)
- * @return string
- *
- */
- function truncate($text, $limit, $break) {
- $size = strlen(strip_tags($text));
- if ($size > $limit) {
- $text = $text." ";
- $text = substr($text,0,$limit);
- $text = substr($text,0,strrpos($text,' '));
- $text = $text.$break;
- }
- return $text;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement