How can I get the first n characters of a string in PHP? What\'s the fastest way to trim a string to a specific number of characters, and append \'...\' if needed?
substr() would be best, you'll also want to check the length of the string first
$str = 'someLongString'; $max = 7; if(strlen($str) > $max) { $str = substr($str, 0, $max) . '...'; }
wordwrap won't trim the string down, just split it up...