user2571510
user2571510

Reputation: 11377

PHP: How to convert ASCII to HTML or how to decode string

I have a database table (SQL Server 2008) with a table that contains some ASCII-encoded characters (formatted as nvarchar(max) ).

Usually the browser converts these automatically to HTML but I use a jQuery plugin that cannot read these and requires the content in HTML. I am passing my content to this plugin using PHP.

Is there a way in PHP to convert such strings manually to HTML ?

Example - db content:

<p>Some sample text with <strong>HTML</strong></p>

Example - required output for plugin:

<p>Some sample text with <strong>HTML</strong></p>

I tried finding a solution myself but it seems there are different approaches available and I wasn't sure about the correct one here.

Upvotes: 0

Views: 3076

Answers (2)

coDe murDerer
coDe murDerer

Reputation: 1876

use this,

echo html_entity_decode($string, ENT_COMPAT, 'UTF-8');

Upvotes: 2

Ram Sharma
Ram Sharma

Reputation: 8819

you can try html_entity_decode();

html_entity_decode('string', ENT_QUOTES, 'UTF-8');

Upvotes: 5

Related Questions