php - HTML string from API not being converted to HTML rendered entities -
i'm receiving chunk of html via api call , trying put html template render. but, instead of rendering, it's being printed out if string.
example of html string api:
\u0026lt;p\u0026gt;\u0026lt;strong\u0026gt;hello world\u0026lt;/strong\u0026gt;\u0026lt;/p\u0026gt;
then in controller convert string html entities
$content = htmlspecialchars_decode($response['content']);
the issue i'm having in view, html printed (tags , all) instead of being rendered html:
in view code:
<?= $content ?>
end result:
<p><strong>hello world</strong></p>
how can html chunk render in view?
your data looks double-encoded. try
$content = htmlspecialchars_decode(htmlspecialchars_decode($response['content']));
Comments
Post a Comment