PHP accessing object stored in an array
<p>I am new to taking an object oriented approach with php...actually I have a lot of learning to do overall, but the only way to learn is by doing.</p>

<p>So I have an array that holds several DateTime objects..I know this to be true because I have ran var_dump on the array and it indeed is holding several objects.</p>

<p>I need to go through each date and make sure there is never a difference greater than one day.</p>

<p>My research would seem to indicate that we cannot access or modify an object using the subscript operator:</p>

<pre><code>$foo = $neat_array[$i+1]-&gt;format('U') ; //looking to format DateTime object as unix

//this returns an error every time
</code></pre>

<p>Okay I am fine with that, but I simply cannot figure out the syntax to access a specific item in the array so that it is seen as an object and does not pull an error.</p>

<p>I have pieced together that using -> is how I need to do it, but I never get any useable result.</p>

<p>Here is pseudo code of what I am trying to do </p>

<pre><code>foreach($date_array as $date)
{

    //check to see if the difference between the next date in the array and the current date of the array is greater than one day.

    //I cannot use diff because I am on php 5.2 so I am trying this

    $date-&gt;format('U') and then doing the math

}
</code></pre>
