Replace ' and similar html codes with their correspondent character?

yes there is: htmlspecialchars_decode($string, ENT_QUOTES);

not sure about the specific ' char, as far as I know htmlspecialchars (with ENT_QUOTES flag) convert an apostrophe (') to ' (with a leading zero)

so the exact behavior on ' worth checking

EDIT: I made the test and it does work :)


You can use html_entity_decode()

It's like reverse htmlentities. If you use quotes in your input string you have to set the second parameter of html_entity_decode() to ENT_QUOTES

See it in action: http://sandbox.onlinephpfunctions.com/code/7f4649eb47a8e639c514787a100b63bbad4bc8c6

Tags:

Php