Good day! I'm putting together an app that has a news section that takes it from a database. Since in the database (which was already made) the texts have several special characters that I want to clean, for which I used htmlentities ($ string) However, when I do that the text disappears.
Without using htmlentities, it looks like this
According to Decree 49/2014 published in the Official Bulletin, the list of pathologies that can be produced by the
When I use it, this is deleted.
I show you the code because maybe something is wrong Thanks!
<?PHP
/* include('lib/helper/ArticleTextExtractor.php'); */
$i = 1;
$SQL_NEWS=" SELECT titulo, copete, cuerpo, imagen, id FROM novedad
ORDER BY orden asc LIMIT 3";
$QUERY_NEWS=mysql_query($SQL_NEWS);
WHILE($NEWS = mysql_fetch_row($QUERY_NEWS)){
// Remove HTML code from the "Cuerpo" field and leave only
paragraphs with article's plain text.
$NEWS_FLAT = extractArticleText($NEWS[2]); */
?>
<div class="col-sm-3 notaHome">
<img src="/web/uploads/novedad/<?php echo $NEWS[3] ?>" class="img-
thumbnail" alt="">
<h4 class="azul tituloNota"><?php echo htmlentities($NEWS[0]) ?></h4>
<hr class="azul">
<h5 class="subtituloPrincipal subtituloNota"><?php echo
htmlentities($NEWS[1]) ?>.</h5>
<?php echo ($NEWS[2]) ?>
<a href="novedadesDetalle.html" id="leerMas" role="button" class="btn
btn-primary">SEGUIR LEYENDO <span class="glyphicon glyphicon-chevron-
right"></span></a>
</div>
<?php
$i++;
}
?>
The code that is commented, I did not. Anyway, call an extractArticleText function that is the following:
<?php
function extractArticleText($htmlString)
{
$replaced = preg_replace("/<a(.|\n)*?>(.|\n)*?<\/a>/", "", $htmlString); // remove anchors
$replaced = preg_replace("/<(.|\n)*?>|( )/", "", $replaced);
//remove HTML tags and
return $replaced;
}
?>
Thank you very much !!