Why does PHP post increment not behave as expected when in an array [ ] operation?
<p>My Question is why does the post increment not function on the first element but then works as expected when it is contained within an array [ ] element ? </p>

<p>Here is a snippet of what I was doing that behaves unexpectedly:</p>

<p>When I use this code ...</p>

<pre><code>$lessonIndex = 0;
$EventArray[$lessonIndex]['Title'] = 'Lesson 1';
$EventArray[$lessonIndex]['Start'] = $TimeArray[$EventArray[$lessonIndex++]['Title']]['Start'];

$EventArray[$lessonIndex]['Title'] = 'Lesson 2';
$EventArray[$lessonIndex]['Start'] = $TimeArray[$EventArray[$lessonIndex++]['Title']]['Start'];

$EventArray[$lessonIndex]['Title'] = 'Lesson 3';
$EventArray[$lessonIndex]['Start'] = $TimeArray[$EventArray[$lessonIndex++]['Title']]['Start'];
</code></pre>

<p>The $EventArray[$lessonIndex] contents will be skip index 0 then index 1 will get what was destined for index 0 and the increment proceeds as expected through the rest of the code, but with the results being off by one.</p>

<p>If I do this instead:</p>

<pre><code>$lessonIndex = 0;
$EventArray[$lessonIndex]['Title'] = 'Lesson 1';
$EventArray[$lessonIndex]['Start'] = $TimeArray[$EventArray[$lessonIndex]['Title']]['Start'];
$lessonIndex++;

$EventArray[$lessonIndex]['Title'] = 'Lesson 2';
$EventArray[$lessonIndex]['Start'] = $TimeArray[$EventArray[$lessonIndex]['Title']]['Start'];
$lessonIndex++;

$EventArray[$lessonIndex]['Title'] = 'Lesson 3';
$EventArray[$lessonIndex]['Start'] = $TimeArray[$EventArray[$lessonIndex]['Title']]['Start'];
$lessonIndex++;
</code></pre>

<p>Everything works as expected.</p>
