function dumpObject($obj)
{
    foreach ($obj as $key => $value) {
        if (is_object($value)) {
            if (is_a($value, 'basicamounttype')) {
                $currency = $value->_attributeValues;
                echo "<tr><td>{$key}:</td><td>{$value->_value} " . $currency["currencyID"] . "</td>";
            } else {
                dumpObject($value);
            }
        } else {
            if ($key[0] != '_' && $value != null) {
                echo "<tr><td>{$key}:</td><td>{$value}</td>";
            }
        }
    }
}
<h1>Order Items</h1><?php 
        foreach ($order_items[$order->Id] as $order_item) {
            dumpObject($order_item, 2);
        }
        if (isset($invoices[$order->Id][0])) {
            ?>
<h1>Invoice</h1><?php 
            dumpObject($invoices[$order->Id][0], 2);
            ?>
<h1>Invoice Items</h1><?php 
            foreach ($invoice_items[$order->Id] as $invoice_item) {
                dumpObject($invoice_item, 3);
            }
            foreach ($invoice_payments[$order->Id] as $invoice_payment) {
                dumpObject($invoice_payment, 3);
                dumpObject($invoice_payment_payments[$invoice_payment->Id], 4);
            }
        }
    }
}
function dumpObject($object, $indent = 0)
{
    if (!is_object($object)) {
        die;
    }
    $data = $object->toArray();
    ?>
        <div style="padding-left: <?php 
    echo $indent * 20;
    ?>
px;">