This question already has an answer here:
i have seen a lot of examples but was unsuccessful to help myself. I have a multidimensional array that i want to convert to object format. I tried going levels deeper (multidimensional) but that all. I want to make it an php object. This is my scenario
// this is my array
Array
(
[_cars] => Array
(
[_car] => Array
(
[0] => Array
(
[_types] => Array
(
[_type] => Array
(
[0] => Array
(
[_cc] => 100
)
[1] => Array
(
[_cc] => 100
)
[2] => Array
(
[_cc] => 1000
)
)
)
)
)
)
)
)
// this is what i want
[_cars] => stdClass Object
(
[_car] => Array
(
[0] => stdClass Object
(
[_types] => stdClass Object
(
[_type] => Array
(
[0] => stdClass Object
(
[_cc] => 999999999999
)
[1] => stdClass Object
(
[_cc] => 999999999999
)
[2] => stdClass Object
(
[_cc] => 999999999999
)
)
)
)
)
)
</div>
Not sure if it will work but you can try
$object = json_decode(json_encode($array));
Please check this if this okay
$obj = new stdClass($array); or
$obj = json_decode(json_encode($array));