We Recommend

Wicked Cool PHP: Real-World Scripts That Solve Difficult Problems Wicked Cool PHP: Real-World Scripts That Solve Difficult Problems
Wicked Cool PHP contains a wide variety of scripts to process credit cards, check the validity of email addresses, template HTML, and serve dynamic images and text.


Posted By

nicolaspar on 08/10/07


Tagged

html entities decode


Versions (?)


Who likes this?

3 people have marked this snippet as a favorite

tylerhall
DeathfireD
silverbux


PHP - unhtmlentities


Published in: PHP 


  1. function unhtmlentities($cadena){
  2. // reemplazar entidades numericas
  3. $cadena = preg_replace('~&#x([0-9a-f]+);~ei', 'chr(hexdec("\\1"))', $cadena);
  4. $cadena = preg_replace('~&#([0-9]+);~e', 'chr(\\1)', $cadena);
  5. // reemplazar entidades literales
  6. $trans_tbl = get_html_translation_table(HTML_ENTITIES);
  7. $trans_tbl = array_flip($trans_tbl);
  8. return strtr($cadena, $trans_tbl);
  9. }

Report this snippet 

You need to login to post a comment.