title: PHP - foreach loop WITH a condition without additional internal IF statement
body: <p><em>I understand that pdo/mysqli is the required standard, for the time being I have no choice other than to use msql</em></p>
  
  <p>Currently I have this setup to loop through results and display them accordingly</p>
  
  <pre><code>foreach($Items as $Item)
  {
      if($Item["Col1"] == "valueFoo"){
          echo "&lt;li&gt;display relevant results&lt;/li&gt;";                   
      }
  } 
  </code></pre>
  
  <p>Is there way I can do this without looping through the whole array if <code>Items</code> and instead combining the foreach loop with a condition. Alternatively filtering the array prior to the <code>foreachloop</code>? What is the most efficient?</p>
  
  <p>Currently I have 60 items and display them in lists like as below</p>
  
  <pre><code>$SQL = "SELECT * FROM tableName WHERE Col1 IS NOT NULL";
  $Data = mysql_query($SQL, $db);
  
  $Items = array();
      while ($NewRow = mysql_fetch_assoc($Data)) {
      // Append all rows to an array
      $Items[] = $NewRow;
  }
  
  echo "&lt;ul&gt;";
  foreach($Items as $Item)
      {
          if($Item["Col1"] == "valueFoo"){
              echo "&lt;li&gt;display relevant results&lt;/li&gt;";                   
          }
      } 
  echo "&lt;/ul&gt;";
  echo "&lt;ul&gt;";
  foreach($Items as $Item)
      {
          if($Item["Col1"] == "valueDoo"){
              echo "&lt;li&gt;display relevant results&lt;/li&gt;";                   
          }
      } 
  echo "&lt;/ul&gt;";
  echo "&lt;ul&gt;";
  foreach($Items as $Item)
      {
          if($Item["Col1"] == "valueHoo"){
              echo "&lt;li&gt;display relevant results&lt;/li&gt;";                   
          }
      } 
  echo "&lt;/ul&gt;";
  </code></pre>
  
  <p>Is there a more efficient way? I'm still a newbie when it comes to php</p>