tags:

views:

32

answers:

2

Hi All,

I have tried lots of things and could not get through yet. I have a json string with some single quotes, double quotes and some other characters which are causing an error when I am trying to iterate the json by converting in into an array.

The quotes are escapes using addslashes and are going correctly in the database. But when I am converting the string to array using json_decode and stripslashes it says invalid argument passed to for loop.

Please suggest.

Thanks in advance.

+1  A: 

Do this on the quotes:

$str = htmlentities($str, ENT_QUOTES);

And they will get-off your way.

shamittomar
A: 

As I remember, you have to first escape the quotes in php, and then escape the quotes and slashes when you print the json_encode. So, for "\"text\"" the output has to be \"\\"text\\"\".

A. M.