Extra loop iteration happening when looping through array of objects
<p>I made this object array </p>

<pre><code>$trailheads[] = new StdClass;
</code></pre>

<p>Then I was putting an object in there each time it looped</p>

<pre><code>$trailheads[] = $trailhead;
</code></pre>

<p>Then I returned the whole thing from the function like this:</p>

<pre><code>$ret-&gt;ok = empty($errors);
$ret-&gt;errors = $errors;
$ret-&gt;o = $trailheads;

return $ret;
</code></pre>

<p>Once I got the values back, and loop through the results in the trailheads[] I keep looping 3 times instead of the expected 2.  Is there a reason an extra iteration might be happening?</p>

<p>Here is how I try to loop:</p>

<pre><code>foreach ($trailhead_list-&gt;o as $key)
{
    $objkey  = (object) $key;
    echo '&lt;p&gt;&lt;h3&gt;Trailhead Name: '.$objkey-&gt;trailhead_name.'&lt;/h3&gt;&lt;/p&gt;';
    }
</code></pre>
