title: Foreach loop in PHP and wordpress
body: <p>What I want is to add category to class only in category page in woocommerce.So for that I am doing like this :</p>
  
  <pre><code>$categories = array('menu','hot-drinks', 'salads', 'sandwiches', 'pastries', 'breakfast', 'sauces', 'cold-drinks', 'breads', 'aroma-signatures', 'soups');
  
  foreach($categories as $cat){
  
      if($_GET['product_cat'] == $cat){  ?&gt;
  
  &lt;div class="left-block"&gt;
  
      &lt;div class="left-navigation-container &lt;?php echo $cat; ?&gt;" &gt; 
  
  &lt;?php }
  } ?&gt;
  </code></pre>
  
  <p>What I want is when there is no product_cat in the URL it should use </p>
  
  <pre><code>&lt;div class="left-block"&gt;
  
      &lt;div class="left-navigation-container"&gt;     
  </code></pre>
  
  <p>But as I used foreach loop, I can't put it else there and I also can't put it outside the loop.</p>
  
  <p>What Should I do ?Any help would be highly appreciated.</p>