title: issues with php if statement within foreach loop
body: <p>I did have a quick search on this but couldn't find anything relating to my problem. I'm having issues with an if statement within a foreach loop. I'm pulling a list of categories from one class, and a single category to be selected from another. The code below (with the if statement removed) works perfectly, and returns 12 options with populated values.</p>
  
  <pre><code>foreach ($user_info-&gt;categories as $key=&gt;$category) {
      $category_name = $user_info-&gt;category_names[$key];
      echo '&lt;option value="'.$category.'"&gt;'.$category_name.'&lt;/option&gt;';
  }
  </code></pre>
  
  <p>However when I add the if statement inside as below:</p>
  
  <pre><code>foreach ($user_info-&gt;categories as $key=&gt;$category) {
      $category_name = $user_info-&gt;category_names[$key];
      if ($category = $get_article_info-&gt;category_1) {
          echo '&lt;option value="'.$category.'" selected="selected"&gt;'.$category_name.'&lt;/option&gt;';
      } else {
          echo '&lt;option value="'.$category.'"&gt;'.$category_name.'&lt;/option&gt;';
      }
  }
  </code></pre>
  
  <p>I get a list of options with the text populated but all twelve options have value="".  $get_article_info->category_1 works when echoed on it's own, and even if it were not found I would expect the if statement to echo 12 options without any selected (the same as the first code example).</p>