Assign an array of objects under $array.
Solution 1: an json_encode array of objects to make it jsonand then convert jsonto associative array.
$result=json_decode(json_encode($array),true);
array_walk_recursive($result, function($value,$key){
print_r($value);
print_r($key);
});
Solution 2: Iterate over the array and cast each type objectas array.
array_walk($array,function(&$value,$key){
$value=(array) $value;
});
array_walk_recursive($array, function($value,$key){
print_r($value);
print_r($key);
});