I have this code to pull the first few words from the body text to use as a title. But, when the body contains apostrophe, it shows on my title as '. I found the following code that's supposedly fixes the code. But, I can't figure out how. I need to add this:
$return = = htmlspecialchars_decode(token_replace($output, 'node', $node), ENT_QUOTES);
Or something similar ... to this:
$limit = 10;
$text = $node->body[$node->language][0]['value'];
$text = strip_tags($text);
$words = str_word_count($text, 2);
$pos = array_keys($words);
if (count($words) > $limit) {
$text = substr( $text, 0, $pos[$limit]);
$text = trim( $text );
$text = rtrim( $text, '.' );
$text = trim( $text ) . '...';
}
return $text;
Thanks in advance.