I've used str_replace
for many characters and it works perfectly. For the life of me it does not work with double quotes. It simply doesn't do anything:
$value = str_replace('"', '', $value);
This does not remove double quotes. Is there some Apache or PHP setting that stops this from working?
Edit: trim($value, '"')
also does not work! I think i'm going mad.
Edit 2: AbraCadaver got it! Thanks it needed "
$value = str_replace(""", "", $value);
Thanks AbraCadaver
You can use that, but first convert the quotes you have which are non-ASCII "curly" quotes to ASCII quotes with this:
$content = iconv("UTF-8", "cp1252//TRANSLIT", $content);
See also: Can I use iconv to convert multi-byte smart quotes to extended ASCII smart quotes?
Just reiniterating what someone else suggested, as it worked for both me and the original poster:
$value = str_replace(""", "", $value);
Although, I was dealing with a single quote issue. What is odd is that the output from my php variable produced a '
in the code, not a '
. If it were '
that output, it wouldn't break the html attribute I was loading it into. Example: <element attr='''>
Not sure myself how to explain. But, glad it got fixed. Hope the original question gets upvoted as it seems not trivial or without effort, but a confusing situation and understandably so.
Here's a related gotchya. I was searching for id="
based on what Chrome DevTools was showing, that being id="identifier"
After loads of time wasted, I did View Source. The generated code was surrounded by single quotes, not double, i.e. id='identifier'