Daniel89 Posted June 25, 2013 Share Posted June 25, 2013 (edited) 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? Edited June 25, 2013 by Daniel89 Quote Link to comment Share on other sites More sharing options...
requinix Posted June 26, 2013 Share Posted June 26, 2013 Are you sure that's the actual output of your script and not, say, what your browser is interpreting? The output isn't actually Quote Link to comment Share on other sites More sharing options...
AbraCadaver Posted June 26, 2013 Share Posted June 26, 2013 Wouldn't you want ENT_QUOTES on both functions? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.