strip_tags() in PHP has several problems. strip_tags () en PHP tiene varios problemas. It doesn’t recognize that css within the style tags are not document text. No reconoce que dentro del css estilo etiquetas no son texto. It will not remove HTML entities or content within script tags. No va a eliminar entidades HTML o script contenido en las etiquetas. strip_tags() fails for invalid HTML. strip_tags () falla por no válidos en HTML. In short strip_tags() is not advisable to use except for trivial cases. En resumen strip_tags () no es recomendable utilizar salvo casos triviales. The best solution I have come across is by uersoy at tnn dot net: La mejor solución que he encontrado es de uersoy a TNN punto net:

 function html2txt($document){   $search = array('@ función html2txt ($ documento) ($ búsqueda = array ( '@  ]*?>.*? ]*?>.*?  @si',  // Strip out javascript                  '@ @ si ', / / Strip de javascript' @  ]*?>.*? ]*?>.*?  @siU',    // Strip style tags properly                  '@<[\/\!]*?[^<>]*?>@si',            // Strip out HTML tags                  '@ Siu @ ', / / Strip etiquetas estilo correctamente' @ <[\ / \ !]*?[^<>]*?>si ', / / Strip de etiquetas HTML' @  @'         // Strip multi-line comments including CDATA   );   $text = preg_replace($search, '', $document);   return $text; } @ '/ / Strip de múltiples líneas comentarios incluidos CDATA), $ texto = preg_replace ($ búsqueda,'', $ documento); retorno $ texto;)