I have a form which is posting JSON encoded data to a Controller function, the reason for this is that the form is dynamic and may contain so many elements that it is limited by Php configuration.
I have no problem retrieving the JSON data in my controller, and I can decode it into an array using:
$result = json_decode($this->request->data['Address']['result'], true);
My issue, however, is that the resultant data is in the following format:
array(
'data[Address][id][0][2087]' => '2087',
'data[Address][id][0][2680]' => '2680',
'data[Address][id][1][3168]' => '3168',
'data[Address][id][1][3911]' => '3911',
'data[Address][id][2][1818]' => '1818',
);
However, I would like to convert it to the CakePHP array style, ie:
array(
'data' => array(
'Address' => array(
'id' => array(
0 => array(
2087 => '2087',
2680 => '2680
),
1 => array(
3168 => '3168',
3911 => '3911'
)
)
)
)
)
I realise this could be done through iteration over the array, but since CakePHP does this already internally, is there some way to simply access that core method and have it convert the array into a multidimensional array?