PHP: Decoding Html Entities
14,005
It's double encoded - Run the string through html_entity_decode()
twice.
echo html_entity_decode( html_entity_decode('<strong>'));
This will output:
<strong>
Author by
JMC
Updated on August 14, 2022Comments
-
JMC over 1 year
I want to decode html entities using php html_entity_decode() but my html entities seem incompatible with the function.
Example Input String: html_entity_decode('&lt;strong&gt;'); Outputs: <strong>
Removing the
'amp;'
solves the problem and produces<strong>
but my file has'amp;'
before every html entity. A mass removal ofamp;
would probably solve the problem, but also very destructive to the html. Is it possible to convert my entities with this situation of an extraamp;
before all entities?