How to convert all HTML entities from a string to their applicable characters in PHP

1 Answer

0 votes
// string html_entity_decode( string $string [, int $flags = ENT_COMPAT | ENT_HTML401 
//                            [, string $encoding = ini_get("default_charset") ]] )

// ENT_COMPAT    convert only double-quotes 
// ENT_QUOTES    convert both double and single quotes
// ENT_NOQUOTES  don't convert double and single quotes

$s = "I'll \"write\" the <b>php</b> code";

$he = htmlentities($s);

$hed = html_entity_decode($he);

echo $he . "<br />";

echo $hed; 


/*
run:

I'll "write" the <b>php</b> code
I'll "write" the php code

*/

 



answered Jun 28, 2016 by avibootz
edited Jun 28, 2016 by avibootz

Related questions

3 answers 319 views
1 answer 200 views
2 answers 202 views
2 answers 235 views
4 answers 491 views
1 answer 195 views
...