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>
Share:
14,005
JMC
Author by

JMC

Updated on August 14, 2022

Comments

  • JMC
    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('&amp;lt;strong&amp;gt;');
    Outputs: &lt;strong&gt;
    

    Removing the 'amp;' solves the problem and produces <strong> but my file has 'amp;' before every html entity. A mass removal of amp; would probably solve the problem, but also very destructive to the html. Is it possible to convert my entities with this situation of an extra amp; before all entities?