I have a code snippet written in PHP that pulls a block of text from a database and sends it out to a widget on a webpage. The original block of text can be a lengthy artic
I know this is old, but...
function _truncate($str, $limit) { if(strlen($str) < $limit) return $str; $uid = uniqid(); return array_shift(explode($uid, wordwrap($str, $limit, $uid))); }