Is there a way to convert a multidimensional array to a stdClass object in PHP?
array
stdClass
Casting as (object) doesn\'t seem to work recu
(object)
function toObject($array) { $obj = new stdClass(); foreach ($array as $key => $val) { $obj->$key = is_array($val) ? toObject($val) : $val; } return $obj; }