PHP: Decoding Html Entities

拜拜、爱过 提交于 2019-12-12 10:42:20

问题


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:


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>


来源:https://stackoverflow.com/questions/11581555/php-decoding-html-entities

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!