Note that there are some explanatory texts on larger screens.

plurals
  1. POiterating through php object elements
    primarykey
    data
    text
    <p>this problem is confusing me as i am sure the syntax is correct (although clearly not :-/)</p> <p>I have an object that looks like this...</p> <pre><code>[result] stdClass Object ( [aResult] =&gt; stdClass Object ( [status] =&gt; 0 [Message] =&gt; Success [container] =&gt; stdClass Object ( [a] =&gt; a [b] =&gt; b [c] =&gt; c [d] =&gt; d [e] =&gt; e [f] =&gt; f [g] =&gt; g [h] =&gt; h [i] =&gt; i [j] =&gt; j ) ) ) </code></pre> <p>No i am trying to pull out the values in the 'container' array. To do this i have the following code...</p> <pre><code>//pull out array result $myDetails = $result-&gt;aResult-&gt;container; foreach( $myDetails as $key) { echo "&lt;p&gt;"; echo "&lt;b&gt;a&lt;/b&gt;: ".$key-&gt;a."&lt;br /&gt;"; echo "&lt;b&gt;b&lt;/b&gt;: ".$key-&gt;b."&lt;br /&gt;"; echo "&lt;b&gt;c&lt;/b&gt;: ".$key-&gt;c."&lt;br /&gt;"; echo "&lt;b&gt;d&lt;/b&gt;: ".$key-&gt;d."&lt;br /&gt;"; echo "&lt;b&gt;e&lt;/b&gt;: ".$key-&gt;e."&lt;br /&gt;"; echo "&lt;b&gt;f&lt;/b&gt;: ".$key-&gt;f."&lt;br /&gt;"; echo "&lt;b&gt;g&lt;/b&gt;: ".$key-&gt;g."&lt;br /&gt;"; echo "&lt;b&gt;h&lt;/b&gt;: ".$key-&gt;h."&lt;br /&gt;"; echo "&lt;b&gt;i&lt;/b&gt;: ".$key-&gt;i."&lt;br /&gt;"; echo "&lt;b&gt;j&lt;/b&gt;: ".$key-&gt;j."&lt;br /&gt;"; echo"&lt;/p&gt;"; } </code></pre> <p>But all i get is the following error for each of the '$key->X' calls...</p> <pre><code>Notice: Trying to get property of non-object in </code></pre> <p>Im honestly unsure what I am doing wrong..... any help is as always greatly appreciated.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload