Posted By

alesma on 01/27/11


Tagged

php words text cut shorten


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

maltem


Shorten text without cutting words


 / Published in: PHP
 

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

  1. $text = substr($text,0,[a number]);
  2. if ( substr($text,-1,1) != ' ' ) $text = substr($text, 0, strrpos($text, " "));

Report this snippet  

You need to login to post a comment.