Reputation: 4914
I have a simple form with buttons and i am using jQuery and an ajax call to save.php. The dataType is set to json.
In save.php i use
$selections= json_encode($_POST['selections']);
The $selections are stored in a mysql column selections (which i thinks is in JSON format)
[{"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
$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
Upvotes: 0
Views: 146
Reputation: 5028
Im not sure what your problem is, but try using
$test = json_decode($row['selections'], true);
Upvotes: 1