For single dimensional array (array) $object works fine. Multi dimension object to array consist of private and protected members.
Example single dimensional:
// Cast to an array $array = (array) $object;</code>
All objects to converted to associative arrays:
function toArray($obj)
{
if (is_object($obj)) $obj = (array)$obj;
if (is_array($obj)) {
$new = array();
foreach ($obj as $key => $val) {
$new[$key] = toArray($val);
}
} else {
$new = $obj;
}
return $new;
}
Reference from here
What do you think?