0
A
回答
0
尝试打印:
json_last_error()
0
亲自serialize();
和unserialize();
功能会更好,如果你想存储在数据库中的数组。 JSON函数应该用于返回到JavaScript的JSON字符串。
$array = array('data','more data','superdata'=>'even more data');
$array = serialize($array);
// Store array in database after serialized
然后把数据传回到一个数组从数据库中,你会......
// Fetch the data from the database
$data = $row['myDataArray'];
$array = unserialize($data);
echo $array['superdata']; // Would produce: "even more data"
希望这会帮助你有点您的问题。如果您确实需要将其转换为JSON以发送到JavaScript,那么您将使用json_encode($array);
函数。
0
我有一个类似的问题,但在不同的上下文中。在我的例子中,我试图解码一个JSON字符串,使用Javascript JSON.stringify
编码,将其存储在隐藏文本字段中,并在页面为POST
ed后将其解码回PHP。我发现,在解码之前应用stripslashes函数是有帮助的。
$arrMyOutput = json_decode(stripslashes($yourJSON_string_goes_here));
相关问题
- 1. json_decode返回NULL [{},{}]
- 2. PHP json_decode返回NULL
- 3. json_decode()返回NULL - PHP
- 4. PHP json_decode返回null
- 5. PHP Json_Decode返回null
- 6. PHP json_decode返回null
- 7. json_decode不断返回null
- 8. PHP的json_decode()返回null
- 9. json_decode返回 “NULL” 帮我
- 10. Json_decode,file_get_contents var_dump返回NULL
- 11. Json to php,json_decode返回NULL
- 12. PHP null返回与json_decode
- 13. Json_decode在收到curl数据后返回NULL,并返回NULL
- 14. json_decode返回null与不同的qoute
- 15. json_decode返回null(特殊字符)
- 16. PHP-json_decode()在使用echo时返回null
- 17. json_decode返回null与PHP,NFL API
- 18. json_decode返回NULL当值为空
- 19. json_decode双引号和逗号返回NULL
- 20. php json_decode每次都返回null
- 21. PHP json_decode带回null
- 22. json_decode从api返回的json数据返回NULL
- 23. json_decode给NULL NULL
- 24. json_decode返回空白
- 25. PHP-json_decode given NULL
- 26. json_decode当数据通过ios时返回null
- 27. 贝宝访问oauth登录json_decode返回null
- 28. json_decode是重整字符串,而不是返回null
- 29. 为什么Json_decode()返回NULL? (在php中解析ebay api)
- 30. 为什么json_decode为空数组返回null?
工作很好。 – 2010-11-28 21:43:20
向我们展示您使用的代码,因为问题可能在于... – 2010-11-28 21:43:32