Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // works with multibyte strings
- // doesn't uses regexes
- function substr_text($string, $length)
- {
- if (mb_strlen($string, 'UTF-8') <= $length)
- {
- return $string;
- }
- else {
- return mb_substr($string, 0, strrpos(mb_substr($string, 0, $length), ' '));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement