Posted By

jmiller on 02/23/10


Tagged

trim String length cut elipses


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

dantreacy


Trim string to certain length and insert ellipses


 / Published in: PHP
 

  1. // Trims a string down to a certain length and inserts an ellipses if it was trimmed.
  2. function cut($str, $len=30) {
  3. if (strlen($str) > $len) {
  4. return substr($str, 0, $len-2) . '&#133';
  5. } else {
  6. return $str;
  7. }
  8. }

Report this snippet  

You need to login to post a comment.