6

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('<strong>');
Outputs: <strong>

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?

1 Answer 1

15

It's double encoded - Run the string through html_entity_decode() twice.

echo html_entity_decode( html_entity_decode('&amp;lt;strong&amp;gt;'));

This will output:

<strong>
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks your answer works perfect. My mistake not pasting in the ending semicolon. That was an insanely fast answer by the way!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.