/ Published in: PHP
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
function myTruncate($string, $limit, $break=".", $pad="...") { // return with no change if string is shorter than $limit return $string; // is $break present between $limit and the end of the string? } } return $string; } /***** Example ****/ $short_string=myTruncate($long_string, 100, ' ');