If statement in PHP For loop not working
<p>I'm trying to add the CSS class "selected" to the first accordionButton div created. Why doesn't this work?</p>

<pre><code>// Create nav from database
                $chapter_array = get_chapter_names();

                for ($i=0; $i &lt; sizeof($chapter_array); $i++) { 
                    if($i == 0) {
                        $selected = 'selected';
                    }
                    echo '&lt;div class="accordionButton '.$selected.'"&gt;'.$chapter_array[$i].'&lt;/div&gt;';

                    $page_id_array = get_page_ids($i);

                    echo '&lt;div class="accordionContent"&gt;';
                    for ($j=0; $j &lt; sizeof($page_id_array); $j++) { 
                        $page_name = get_page_name($page_id_array[$j]);
                        echo '&lt;a href="?page_id='.$page_id_array[$j].'"&gt;'.$page_name.'&lt;/a&gt;&lt;br /&gt;';
                    }
                    echo '&lt;/div&gt;';
                }
</code></pre>
