Avoid using substr. Why?
If you use substr(), it may truncate HTML end tags and return invalid HTML.
Do not reinvent the wheel!
WordPress 3.3 wp_trim_words().
wp_trim_words Break Down:
wp_trim_words($text, $num_words, $more);
$text
(string) (required) Text to trim
Default: None
$num_words
(integer) (optional) Number of words
Default: 55
$more
(string) (optional) What to append if $text needs to be trimmed.
Default: '…'
:
<?php echo wp_trim_words(get_the_content(), 40, '...'); ?>
<?php echo wp_trim_words(get_the_excerpt(), 20, '... read more...'); ?>