I'm trying to remove certain html tags inside a variable $articlescontent which comes from a database field with some html tags that we won't use, so initially I put the tags to be removed in an array to replace it with blank spaces and ready.
//Etiquetas html para eliminar desde el campo contenidos en la base de datos.
$eliminarHtml = array('<p>', "</p>", "<u>", "</u>", "<a>", "</a>","<strong>", "</strong>", "<em>", "</em>");
//Reemplazar por espacios vacios
$contenidoSinHtml = str_replace($eliminarHtml, "", $contenidoArticulos);
So far so good, however I see that some of the tags with long links within the content are not removed, such as this one:
Artículo sobre las plantas donde.. <a href="http://www.web.com/sobre-las-plantas/a574">Título del enlace </a>
In that case, how can I remove it?
I have come up with this option but I am not able to get it out:
//Si en el array o el contenido $contenidoArticulos existe <a href
//Contar la cantidad total de caracteres de principio a fin (desde <a href hasta >Título enlace </a>)
//Contar la cantidad de caracteres en total
$cadenaEncontrada = '<a href=" ';
echo strlen ($cadenaEncontrada);
//Eliminar toda la cantidad total de caracteres encontrados en $cadenaEncontrada
Is it possible to do something like that?
finally using this function I fix said problem.
php.net/manual/en/function.strip-tags.php
Thank you both for the help, greetings.