PHP - unhtmlentities


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.