Función para convertir tildes y caracteres especiales en formato HTML


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

Función especial para convertir una cadena de texto en entidad HTML tomando en cuenta si hay etiquetas.


Copy this code and paste it in your HTML
  1. function html_chr($texto) {
  2. $salida = "";
  3. for ($i=0; $i<strlen($texto); $i++) {
  4. if (eregi("[A-Z 0-9<>\"]", substr($texto, $i, 1))) {
  5. $salida .= substr($texto, $i, 1);
  6. } else {
  7. $salida .= htmlentities(substr($texto, $i, 1));
  8. }
  9. }
  10. return $salida;
  11. }

URL: http://www.ariskelvyn.com

Report this snippet


Comments


You need to login to view comments.