[英]What's wrong with my use of json_decode?
我有一个带有按钮的简单表单,我正在使用jQuery和ajax调用save.php。 dataType设置为json。
在save.php中,我使用$selections= json_encode($_POST['selections']);
$ selections存储在mysql列选择中(我认为这是JSON格式)
[{"arrA":["a1","a3","a5","a8"]},{"arrB":["a1","a8"]},{"arrC":["a1"]}]
现在在show.php中,我想解析数组,我设法用
$test = json_decode($row['selections']); echo 'Array A: '.$test[0]->arrA[0]. ' |'.$test[0]->arrA[1]. ' |'.$test[0]->arrA[2]. ' |'.$test[0]->arrA[3].'<br/>';
我有感觉我做错了什么,看到了吗?
问候
我不确定您的问题是什么,但请尝试使用
$test = json_decode($row['selections'], true);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.