title: Echo selected value first
body: <p>I need to echo the selected value first in a form when user wants to make an update. I tried several variants:</p>
  
  <p>1)  </p>
  
  <pre><code>&lt;?php 
    $opt= array('1' =&gt; 'opt1', '2' =&gt; 'opt2', '3' =&gt; 'opt3') ;
    echo '&lt;select name="up_opt" &gt;' ;
  
    foreach ($opt as $i =&gt; $value) {
      echo "&lt;option value=\"$i\"";
      if ($_REQUEST['up_opt'] == $i) 
      {
        echo "selected" ; 
      }
      echo "&gt;$opt[$i]&lt;/option&gt;" ;
    }
    echo '&lt;/select&gt;' ;
  ?&gt;
  </code></pre>
  
  <p>2)</p>
  
  <pre><code>&lt;?php $opt= array('1' =&gt; 'opt1', '2' =&gt; 'opt2', '3' =&gt; 'opt3') ;
    $edu = $_REQUEST['edu']; 
    &lt;select name="up_opt"&gt;     
      &lt;?php foreach ( $opt as $i=&gt;$opt ) : ?&gt;       
        &lt;option value="&lt;?php echo $i?&gt;" &lt;?php echo $i == $edu ? 'selected' : ''?&gt;&gt;&lt;?php echo $opt ?&gt;&lt;/option&gt;
      &lt;?php endforeach; ?&gt;
    &lt;/select&gt;
  </code></pre>
  
  <p>3)</p>
  
  <pre><code>&lt;select name="up_opt"&gt;
      &lt;option value="1" &lt;?php if ($_GET['1'] == 'option1') { echo 'selected'; } ?&gt;&gt;Opt1&lt;/option&gt;
      &lt;option value="2" &lt;?php if ($_GET['2'] == 'option2') { echo 'selected'; } ?&gt;&gt;Opt2&lt;/option&gt;
      &lt;option value="3" &lt;?php if ($_GET['3'] == 'option3') { echo 'selected'; } ?&gt;&gt;Opt3&lt;/option&gt;
   &lt;/select&gt;
  </code></pre>
  
  <p>None of these variants echoes the checked value first. Can someone help me, tell me what is wrong or give me another variant? </p>