1

I have a string like this:

{\"lat\":37.790388261934424,\"lng\":-122.46047996826172},{\"lat\":37.789608231530124,\"lng\":-122.46344112701416}

And when I tried to get rid of the double quotes with something like this:

$data = str_replace('\"','"',$date);

I got this error:

Unexpected character in input:  '\\' (ASCII=92) state=1

I also got that error running the following without the previous line:

$data = json_decode($data);

Any ideas why this is happening? Is this a sign that I am escaping twice somewhere? Or is the issue something else?

2
  • Did you try stripslashes yet? Nest it twice, if need be. Commented Apr 3, 2011 at 3:10
  • can you please show us the full code of assigning the variable up to the json_decode? Commented Apr 3, 2011 at 3:10

1 Answer 1

3

Don't use str_replace() to strip off slashes. Use stripslashes().

Something like this:

$data = json_decode(stripslashes($data));
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.