Read More]'; //http://www.sharejs.com function strLength($str,$len){ $lenght = strlen($str); if($lenght > $len){ return substr($str,0,$len).'...'; }else{ return $str; } } $str = "This is a fairly long string."; //The fist part is the string, the second part is how long it can be echo strLength($str,10).'
'; echo strLength($str,30); ?> //php/8895