issues with quotes in json string :php

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.


Do this on the quotes:

$str = htmlentities($str, ENT_QUOTES);

And they will get-off your way.


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"".

链接地址: http://www.djcxy.com/p/37858.html

上一篇: ''“'是一个有效的JSON字符串吗?

下一篇: 在json字符串中引号问题:php