i have js object
data=[{'quest':'sometext'},{'option':['a','b', 'c']}, {'cor':[0,1,0]},{'sol':'again tetx'}]
Submited as ajax data using jquery
... data:{'qs':JSON.stringify(data)}, ...
i recieved the as post and try to convert to array
$array=json_decode(json_encode($_POST['qs']), true);
but output is
print_r($array); \\is
[{"quest":"sometext"},{"option":["a","b", "c"]}, {"cor":[0,1,0]},{"sol":"again tetx'}]
i want to make it array in php
CodePudding user response:
$array = json_decode($_POST['qs'], true);
print_r($array);
Output:
Array
(
[0] => Array
(
[quest] => sometext
)
[1] => Array
(
[option] => Array
(
[0] => a
[1] => b
[2] => c
)
)
[2] => Array
(
[cor] => Array
(
[0] => 0
[1] => 1
[2] => 0
)
)
[3] => Array
(
[sol] => again tetx
)
)