For special characters like áéí, I can call htmlentities()
:
$mycaption = htmlentities($mycaption, ENT_QUOTES);
To get the corresponding html entities:
áéí
How can I reverse this back to áéí ?
The un-escape tool removes all html entities from the text and returns clean text.
htmlentities() Function: The htmlentities() function is an inbuilt function in PHP that is used to transform all characters which are applicable to HTML entities. This function converts all characters that are applicable to HTML entities. Syntax: string htmlentities( $string, $flags, $encoding, $double_encode )
This function returns a string with these conversions made. If you require all input substrings that have associated named entities to be translated, use htmlentities() instead.
The htmlspecialchars() function converts some predefined characters to HTML entities.
If you use htmlentities()
to encode, you can use html_entity_decode()
to reverse the process:
Convert all HTML entities to their applicable characters.
html_entity_decode() is the opposite of htmlentities() in that it converts all HTML entities in the string to their applicable characters.
e.g.
$myCaption = 'áéí'; //encode $myCaptionEncoded = htmlentities($myCaption, ENT_QUOTES); //reverse (decode) $myCaptionDecoded = html_entity_decode($myCaptionEncoded);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With