I have following string:
ab"wefdty?'aaavvv
After submitting the data it shows like this :
ab'wefdty?"aaavvv
I tried with htmlspecialCharacters, htmlentities but it won’t work. How should I get the original text back?
I have following string:
ab"wefdty?'aaavvv
After submitting the data it shows like this :
ab'wefdty?"aaavvv
I tried with htmlspecialCharacters, htmlentities but it won’t work. How should I get the original text back?
2
Answers
You should use the html_entity_decode function :
https://www.php.net/manual/en/function.html-entity-decode.php
You can use following PHP functions as both are valid approaches:
But htmlspecialchars_decode() is limited as it only decodes some characters:
(&, " (double quote), ‘< (less than), and ‘ (greater than)).
If your encoded string includes other HTML entities, html_entity_decode() would be more comprehensive.
To decode entities back to their original characters in PHP, you can do it in following way: