SELECTED not working with <option> tag inside a for loop/ while loop
<p>i want one of the options in drop down to be selected by default,  Please see the code</p>

<pre><code>&lt;?php
class html{

    function output(){

        $html='&lt;td&gt;'.'&lt;select id="out"&gt;';
        for($i=0;$i&lt;21;$i++){
            $html.='&lt;option value="$i" if($i==5) { selected } &gt;'. $i .'&lt;/option&gt;';
        }

        return $html;
    }
}

echo html::output();
?&gt;
</code></pre>

<p>Here i want value 5 to be selected by default,But I am getting selected value as 20.  THANK YOU!!</p>
