Connecting Tech Pros Worldwide Forums | Help | Site Map

display text retrieved with html tags

Newbie
 
Join Date: Nov 2006
Posts: 3
#1: Nov 14 '08
In one of the web sites I Really got an excellent code to convert text entered in ms word to html format

I am using following code for conversion

Expand|Select|Wrap|Line Numbers
  1. <?php 
  2. $txt= superhtmlentities($rrows['detail']);
  3. echo $txt ;?>
  4.  
  5. The function is given below
  6.  function superhtmlentities($text) { 
  7. $entities = array(128 => 'euro', 130 => 'sbquo', 131 => 'fnof', 132 => 'bdquo', 133 => 'hellip', 134 => 'dagger', 135 => 'Dagger', 136 => 'circ', 137 => 'permil', 138 => 'Scaron', 139 => 'lsaquo', 140 => 'OElig', 145 => 'lsquo', 146 => 'rsquo', 147 => 'ldquo', 148 => 'rdquo', 149 => 'bull', 150 => '#45', 151 => 'mdash', 152 => 'tilde', 153 => 'trade', 154 => 'scaron', 155 => 'rsaquo', 156 => 'oelig', 159 => 'Yuml'); 
  8. $new_text = ''; 
  9. for($i = 0; $i < strlen($text); $i++) { 
  10. $num = ord($text{$i}); 
  11. if (array_key_exists($num, $entities)) { 
  12. switch ($num) { 
  13. case 150: 
  14. $new_text .= '-'; 
  15. break; 
  16. default: 
  17. $new_text .= '&'.$entities[$num].';'; 
  18. else 
  19. if($num < 127 || $num > 159) { 
  20. $new_text .= htmlentities($text{$i}); 
  21. return $new_text; 
where superhtmlentities is function defined in this section above

the output i.e. $txt stores

<p><b>The pages in this section will give the details of various hospitals and the centers for special treatments in Mumbai. The addresses and contact details for the same have been provided. This page is updated with the special concessions that are provided to Senior Citizens wherever available.</b></p>

which is text with an html code ,,,
How can i display this as nomal text with html format

how to display it ?

Help

Thanks in advance

Markus's Avatar
Moderator
 
Join Date: Jun 2007
Location: York, England, with wolves.
Posts: 4,949
#2: Nov 14 '08

re: display text retrieved with html tags


Using htmlentities causes this. Remove the htmlentities() function on line 22
Markus's Avatar
Moderator
 
Join Date: Jun 2007
Location: York, England, with wolves.
Posts: 4,949
#3: Nov 14 '08

re: display text retrieved with html tags


Vikaspa, when posting code on the forums, use [code] tags. To do this, highlight the code and then hit the '#' button (not the one on your keyboard) at the top of where you enter your text. Read the Posting Guidelines if you are unsure how to do this.

Moderator.
Reply