Ethan Allen
Ethan Allen

Reputation: 14835

Is there a quick and easy way to replace all Unicode characters with their HTML equivalent in PHP?

Right now I use this page to do this:

http://www.w3schools.com/tags/ref_symbols.asp

$info = str_replace("©", "©", $info);
$info = str_replace("®", "®", $info);
$info = str_replace("•", "•", $info);
$info = str_replace("½", "½", $info);
$info = str_replace("é", "é", $info);
$info = str_replace("€", "€", $info);

Is there a quick way (like a single PHP function) that can do ALL of the HTML conversions for me?

Upvotes: 0

Views: 88

Answers (1)

elliotanderson
elliotanderson

Reputation: 452

PHP has a built in function, htmlentities. In your case, you would want to do this:

$info = htmlentities($info);

Upvotes: 2

Related Questions