a coder
a coder

Reputation: 7639

Converting special characters to generic equivalents (PHP)

Is there an efficient way to convert special entities (such as &mdash) to its logical generic equivalent (such as -)? The manual states that I can convert the actual character to its html entity, but this is going in the opposite direction. It's important to be able to switch out the entity for something generic. Another example.. &rdquo would become a simple " in this so far fictitious function.

Helpz?

Upvotes: 0

Views: 95

Answers (2)

Quentin
Quentin

Reputation: 943142

Use iconv and turn transliteration on.

$text = "—”";
echo iconv("UTF-8", "ASCII//TRANSLIT", $text), PHP_EOL;

Upvotes: 1

qJake
qJake

Reputation: 17119

Why won't html_entity_decode do what you want?

Upvotes: 4

Related Questions