PHP - Array to object - Issue when getting object variable by index
<p>I am just trying to understand why the last two <code>print_r()</code> calls below are not working and throws the following error <code>Undefined property: stdClass::$0</code>. According to the PHP Documentation, I should be able to access the object numeric property using the the following operator <code>$object-&gt;{'x'}</code> ( x is the numeric index I want to access ).</p>

<p>Thanks.</p>

<pre><code>$array = (object)array( 
    0 =&gt; 'test1',
    1 =&gt; 'test2',
    2 =&gt; 'test3',
    'test' =&gt; (object)array(
        0 =&gt; 'hi1',
        1 =&gt; 'hi2',
        2 =&gt; 'hi3'
    )
);

print_r( $array );

print_r( $array-&gt;test );

print_r( $array-&gt;test-&gt;{'0'} );

print_r( $array-&gt;{'0'} );

die();
</code></pre>
