Pierre
Pierre

Reputation: 51

str_replace works with single quote but not double

Hi have the following code:

$ItemDescriptionNEW = str_replace('\"', '"',$ItemDescription);
$ItemDescriptionNEW = str_replace('\'', ''', $ItemDescriptionNEW);

When I execute it, only the single quote get replaced. I've been looking for the problem for the past hour and can't figure it out...

Upvotes: 1

Views: 47

Answers (1)

Rizier123
Rizier123

Reputation: 59701

You have to remove the backslash where you use it with the double quote. Because you don't have to escape anything. So just use this:

$ItemDescriptionNEW = str_replace('"', '"',$ItemDescription);

Upvotes: 4

Related Questions