Skip to content
Advertisement

removing strange characters from php string

this is what i have right now

Drawing an RSS feed into the php, the raw xml from the rss feed reads:

Paul’s Confidence

The php that i have so far is this.

$newtitle = $item->title;
$newtitle = utf8_decode($newtitle);

The above returns;

Paul?s Confidence

If i remove the utf_decode, i get this

Paul’s Confidence

When i try a str_replace;

$newtitle = str_replace("”", "", $newtitle);

It doesnt work, i get;

Paul’s Confidence

Any thoughts?

Advertisement

Answer

Try this:

$newtitle = html_entity_decode($newtitle, ENT_QUOTES, "UTF-8")

If this is not the solution browse this page http://us2.php.net/manual/en/function.html-entity-decode.php

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement