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

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -