I am retrieving text and HTML tags from a database while using this function to encode the values for the browser.
foreach ($row as $key => &$value){
$value = htmlspecialchars_decode(
htmlentities($value,ENT_QUOTES),
ENT_NOQUOTES
);
}
Basically, I am looping through each row and converting quotes, single quotes, and other special characters to entities while keeping HTML tags.
However, when there's tags like
<a href="example.com">
the quotes are duplicated twice and outputs to this:
<a href=""example.com"">
What am I doing wrong?