So geht’s:

function object2Array($object)
{
  $array = array();
  foreach ($object as $key => $value) {
    $array[$key] = object2Array($value);
  }
  return $array;
}

 Oder in die anderer Richtung.