Mark
Mark

Reputation: 245

Decode symbols in string

echo $name gives me Mount Kimbie — Carbonated.

How do I get Mount Kimbie — Carbonated?

&mdash, quotes and other stuff should be decoded into regular symbols.

I've tried both htmlspecialchars_decode($name) and html_entity_decode($name), they don't work.

Upvotes: 2

Views: 929

Answers (2)

MatthewMcGovern
MatthewMcGovern

Reputation: 3496

html_entity_decode() works fine for me? Edit: This uses your PHP versions default charset which for me is UTF-8. Your default charset may not support —

Note that it returns the string and does not edit the string itself so try:

$name = html_entity_decode($name);
echo $name;

Upvotes: 0

mario
mario

Reputation: 145482

You probably lack the charset parameter:

html_entity_decode($name, 0, "UTF-8");

Depending on PHP version, Latin-1 was assumed, which does not harbor mdash.

Upvotes: 11

Related Questions