Convert this array:
Array
(
[0] => Array
(
[TEST] => Array
(
[name] => John Snow
[id] => 2
)
[HELLO] => Array
(
[stuff] => what
[more] => 0
)
)
[1] => Array
(
[TEST] => Array
(
[name] => Arya Stark
[id] => 3
)
[HELLO] => Array
(
[stuff] => dsfsdf dfsd
[more] => 3
)
)
[2] => Array
(
[TEST] => Array
(
[name] => Tyrion Lannister
[id] => 7
)
[HELLO] => Array
(
[stuff] => test
[more] => 2
)
)
)
To:
stdClass Object
(
[1] => stdClass Object
(
[TEST] => stdClass Object
(
[name] => John Snow
[id] => 2
)
[HELLO] => stdClass Object
(
[stuff] => what
[more] => 0
)
)
[2] => stdClass Object
(
[TEST] => stdClass Object
(
[name] => Arya Stark
[id] => 3
)
[HELLO] => stdClass Object
(
[stuff] => dsfsdf dfsd
[more] => 3
)
)
[3] => stdClass Object
(
[TEST] => stdClass Object
(
[name] => Tyrion Lannister
[id] => 7
)
[HELLO] => stdClass Object
(
[stuff] => test
[more] => 2
)
)
)
We can have more than one array within each level. This is just dummy data and the names are never TEST or HELLO, and can be anything. Let me know if you guys need more info!
Here's what I have so far:
function (&$data, $index) {
$object = new stdClass();
$output = array();
foreach ($data as $key => $value) {
$object->$key->$index = $value[$index];
}
return $object;
};