Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

htmlspecialchars_decode() dosen't work with spaces

Tags:

php

decode

I'm trying to use htmlspecialchars_decode() but it don't decoding   into spaces. Are any solutions of this problem?

My code:

$query = mysql_query("select * from nowosci order by id desc limit 0,3");
while($rekord = mysql_fetch_array($query))
{
$tekst .= '<h1 class="body"><div class="date" style="display:inline; color:grey; margin-right:5px;">'.$rekord[3].'</div>'.html_entity_decode($rekord[1]).'</h1><div class="main">'.html_entity_decode($rekord[2]).'</div>';
}
echo $tekst
like image 543
user192012 Avatar asked Feb 20 '23 16:02

user192012


2 Answers

Use html_entity_decode() instead.

htmlspecialchars_decode() only decodes &amp; &quot; (when ENT_NOQUOTES is not set), &#039; (when ENT_QUOTES is set), &lt; and &gt;.

like image 166
laurent Avatar answered Mar 04 '23 13:03

laurent


htmlspecialchars_decode() decodes htmlspecialchars and it's not supposed decode &nbsp; as this does not belong to htmlspecialchars. you can look at htmlspecialchars list.

you can use html_entity_decode(); instead.

like image 36
loler Avatar answered Mar 04 '23 11:03

loler