Posted By

nicolaspar on 08/10/07


Tagged

html entities decode


Versions (?)

Who likes this?

4 people have marked this snippet as a favorite

tylerhall
DeathfireD
silverbux
vali29


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.