Shorten text without cutting words

/ Published in: PHP
Save to your folder(s)

This help you cutting text without cut the last word. Any feedback appreciated!

Copy this code and paste it in your HTML
  1. $text = substr($text,0,[a number]);
  2. if ( substr($text,-1,1) != ' ' ) $text = substr($text, 0, strrpos($text, " "));

Report this snippet


RSS Icon Subscribe to comments

You need to login to post a comment.