简体   繁体   English

我使用json_decode有什么问题?

[英]What's wrong with my use of json_decode?

I have a simple form with buttons and i am using jQuery and an ajax call to save.php. 我有一个带有按钮的简单表单,我正在使用jQuery和ajax调用save.php。 The dataType is set to json. dataType设置为json。

In save.php i use $selections= json_encode($_POST['selections']); 在save.php中,我使用$selections= json_encode($_POST['selections']);

The $selections are stored in a mysql column selections (which i thinks is in JSON format) $ selections存储在mysql列选择中(我认为这是JSON格式)

[{"arrA":["a1","a3","a5","a8"]},{"arrB":["a1","a8"]},{"arrC":["a1"]}]

Now in show.php i like to parse the arrays and i manage to do this with 现在在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/>';

I have the feeling i am doing something wrong, do you see it? 我有感觉我做错了什么,看到了吗?

regards 问候

我不确定您的问题是什么,但请尝试使用

$test = json_decode($row['selections'], true);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM