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. json_decode()返回NULL - PHP
- 3. PHP json_decode返回null
- 4. PHP json_decode返回NULL
- 5. json_decode返回 “NULL” 帮我
- 6. Json_decode,file_get_contents var_dump返回NULL
- 7. Json_decode在收到curl数据后返回NULL,并返回NULL
- 8. PHP json_decode带回null
- 9. json_decode返回null(特殊字符)
- 10. json_decode返回NULL当值为空
- 11. php json_decode每次都返回null
- 12. json_decode是重整字符串,而不是返回null
- 13. 当使用etsy API时,json_decode返回undefined/null
- 14. json_decode在已通过加密的字符串上返回NULL
- 15. 贝宝访问oauth登录json_decode返回null
- 16. 为什么Json_decode()返回NULL? (在php中解析ebay api)
- 17. Json_decode什么都不返回
- 18. json_decode返回数组1
- 19. 为什么json_decode()返回空?
- 20. null == null返回false?
- 21. PropertyInfo.GetValue(null,null)返回null
- 22. json_decode返回数组1与mysqli
- 23. json_decode返回一个嵌套的数组?
- 24. PHP json_decode返回数组和数字键
- 25. 从json_decode输出中获取返回值
- 26. php json_decode不返回任何结果
- 27. UISwitch返回NULL?
- 28. getElementById返回null
- 29. ListView.getTag()返回null
- 30. LocationManager返回null
工作很好。 – 2010-11-28 21:43:20
向我们展示您使用的代码,因为问题可能在于... – 2010-11-28 21:43:32