PHP Sum up JSON Object value
<p>I know this sounds silly but how do I get the total sum of all the object's total?</p>

<p>My json decode format looks something like this:</p>

<pre><code>Array
(
[results] =&gt; Array
    (
        [0] =&gt; Array
            (
                [total] =&gt; 22   
            )
        [1] =&gt; Array
            ( 
                [total] =&gt; 10
            )
     )
)   
</code></pre>

<p>I've tried using writing something like this but it shows "Trying to get property of non-object in..."</p>

<pre><code>echo 'Array Total&lt;pre&gt;';
$sum = 0;
foreach ( $receipt_data['results'] as $receipt )
{
    $sum += $receipt-&gt;total;
}
echo '&lt;/pre&gt;';
</code></pre>