JSON to PHP error - array : <p>I'm having problems getting data from JSON with PHP. </p>

<p>json string</p>

<pre><code>{"cpresult":{"apiversion":"2","error":"Access denied","data":{"reason":"Access denied","result":"0"},"type":"text"}}
</code></pre>

<p>Same json decoded</p>

<pre><code>    array (
  'cpresult' =&gt; 
  array (
    'apiversion' =&gt; '2',
    'error' =&gt; 'Access denied',
    'data' =&gt; 
    array (
      'reason' =&gt; 'Access denied',
      'result' =&gt; '0',
    ),
    'type' =&gt; 'text',
  ),
)
</code></pre>

<p>PHP code</p>

<pre><code>    $get_accounts = json_decode($get_accounts);
echo $get_accounts['cpresult']['data'][0]['result'];
</code></pre>

<p>error: Fatal error: Cannot use object of type stdClass as array</p>
