Reputation: 21
Have tried every solution here and still nothing. This is var_dump string(19) ""Example"". I just need to remove double quotes from name so "Example" should be Example Tried with trim, preg_replace, substr.
I think that there is problem somewhere else but I dont have much experience with PHP so I am stuck.
Upvotes: 0
Views: 8369
Reputation: 161
Try trim($string, '"');
and take some time to learn about HTML entities.
What's happening is the double quotes are html entities, so as you've seen in var_dump the string is not "Movie Title"
but &x#22;Movie Title&x#22;
. There is no literal double quote in the string for the function to trim, so it fails. You need to trim the entity instead.
Upvotes: 1
Reputation: 426
If
str_replace('"', '', $a)
does not work, maybe that is not a single double quote, but it's analogue, like ¨
Upvotes: 1
Reputation: 43169
Here we go:
<?php
$str = '""Example""';
$str = str_replace('"', '', $str);
echo $str;
?>
You can even see a demo on ideone.com.
Upvotes: 5