I have a problem with getting some html value stored in a php array:
$data = array("Name"=>'<div style="color:red"></div>');
while(list($key,$val) = each($data)){
print_r($key." => ".$val) ;
}
The problem is that the script (put inside html tags) returns:
Name =>
Foo Bar
So, the div (so the html) is interpretated.
What I want to display is the value, not its interpretation. So, the result that I want is:
Name => <div style="color:red">Foo Bar</div>
Is there a way to do that?
Thank you very much,
Regards.
If you want to display the actual HTML as stored in your array, then you need to convert the special characters into HTML entities using
htmlentities(), orhtmlspecialchars(). ie. you need to convert<into<to display the character correctly on the page.htmlentities()converts all characters that have HTML entity equivalents.htmlspecialchars()converts just the essentials.