I’m generating a multi-dimensional array in javascript that looks like this (this is the JSON representation of the javascript array, it’s not in JSON format):
"100": {
"40": {
"subtotal": "24.99",
"turn-around": {
"0": "2-4 Business Days",
"1": "Next Business Day (Add $15.00)"
},
"shipping": {
"0": "UPS Ground - $0.00",
"1": "UPS 2nd Day Air - $14.73",
"2": "UPS 3 Day Select - $13.13"
}
},
"41": {
"subtotal": "29.99",
"turn-around": {
"0": "2-4 Business Days",
"1": "Next Business Day (Add $15.00)"
},
"shipping": {
"0": "UPS Ground - $0.00",
"1": "UPS 2nd Day Air - $14.73",
"2": "UPS 3 Day Select - $13.13"
}
}
}
I’m trying to convert this to JSON format, so I can import this to a PHP script. I’m using the JSON.stringify, but only getting the result:
[null,null,null,null,null,null,null,null,... CLIP... null,null,null,null,null,null,null,null,null,[]]]
I’m pretty sure the array’s correct, because when dumping the contents, I get this:
'1000' ...
'41' ...
'subtotal' => "$24.00"
'tat' ...
'0' => "- Choose Turnaround Time -"
'1' => "Next Business Day (Add $15.00)"
'2' => "2-4 Business Days"
'shipping' ...
'0' => "FREE UPS Ground - $0.00"
'1' => "UPS 2nd Day Air - $12.75"
'2' => "UPS 3 Day Select - $13.13"
'3' => "UPS Next Day Air Saver - $15.32"
'4' => "UPS Next Day Air - $17.04"
'5' => "UPS Next Day Air Early A.M. - $71.61"
I’m not sure why the JSON.stringify method is not working. All I need it to get the array into a readable format to digest in PHP. Perhaps there’s a better way?
All I need is to get a multi-dimensional array in javascript to a multi-dimensional array in PHP. I’m not a javascript expert, so that could be the real problem here.
Since you are able to send the json data to php, you can do convert it using php too with its
json_decodefunction.