Jump to content

Html Special Character on Fields


zeta1600

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.