Posted By

vanity on 12/08/06


Tagged

php String limit


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

vali29
skywalker


Limit String


 / Published in: PHP
 

URL: http://www.subeta.org

  1. function limit_string($string, $charlimit)
  2. {
  3. if(substr($string,$charlimit-1,1) != ' ')
  4. {
  5. $string = substr($string,'0',$charlimit);
  6. $array = explode(' ',$string);
  7. array_pop($array);
  8. $new_string = implode(' ',$array);
  9.  
  10. return $new_string.'...';
  11. }
  12. else
  13. {
  14. return substr($string,'0',$charlimit-1).'...';
  15. }
  16. }

Report this snippet  

You need to login to post a comment.