zeta1600 Posted January 24, 2012 Share Posted January 24, 2012 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. Link to comment https://forums.phpfreaks.com/topic/255697-html-special-character-on-fields/ Share on other sites More sharing options...
dzelenika Posted January 24, 2012 Share Posted January 24, 2012 is this code part of a function that returns text? Link to comment https://forums.phpfreaks.com/topic/255697-html-special-character-on-fields/#findComment-1310776 Share on other sites More sharing options...
AyKay47 Posted January 25, 2012 Share Posted January 25, 2012 $text = htmlspecialchars_decode($text, ENT_QUOTES); Link to comment https://forums.phpfreaks.com/topic/255697-html-special-character-on-fields/#findComment-1310844 Share on other sites More sharing options...
monkeybidz Posted January 25, 2012 Share Posted January 25, 2012 Your code: $return = = htmlspecialchars_decode(token_replace($output, 'node', $node), ENT_QUOTES); Try: $return = htmlspecialchars_decode(token_replace($output, 'node', $node), ENT_QUOTES); Link to comment https://forums.phpfreaks.com/topic/255697-html-special-character-on-fields/#findComment-1310926 Share on other sites More sharing options...
zeta1600 Posted January 25, 2012 Author Share Posted January 25, 2012 AyKay47... thank you! thank you! I don't know how to mark this resolved... Link to comment https://forums.phpfreaks.com/topic/255697-html-special-character-on-fields/#findComment-1311091 Share on other sites More sharing options...
AyKay47 Posted January 25, 2012 Share Posted January 25, 2012 no problem, the topic solved button is in the lower left hand corner of this thread. Link to comment https://forums.phpfreaks.com/topic/255697-html-special-character-on-fields/#findComment-1311132 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.