I am using a custom function in my Wordpress theme to limit the length of the excerpt that is displayed. Currently my function is limiting the number of words but I would like to modify it so that it limits the number of characters instead. Here is what I have for my custom function:
function limit_words($string, $word_limit) {
$words = explode(' ', $string);
return implode(' ', array_slice($words, 0, $word_limit));
}
And I'm calling it in my template like so:
<?php echo limit_words(get_the_excerpt(), '100'); ?>
How can I modify this function to restrict the content to 100 characters rather than words?