title: Limit this PHP foreach statement to just 5 loops
body: <p>How could I limit this foraech statement to just 5 loops? I think I should just use Break but I'm not sure where to put it. </p>
  
  <pre><code> &lt;?php if(!empty($locations)): foreach($locations as $location):  ?&gt;
  &lt;?php if(empty($location["title"])) continue; ?&gt;
  &lt;li&gt;
      &lt;a href="&lt;?php esc_attr_e($url.$glue.http_build_query($location["query"])) ?&gt;"&gt;
          &lt;?php esc_html_e($location["title"]) ?&gt;
      &lt;/a&gt;
      &lt;?php if($param-&gt;count): ?&gt;
      &lt;div class="wpjb-widget-item-count"&gt;
          &lt;div class="wpjb-widget-item-num"&gt;&lt;?php echo intval($location["count"]) ?&gt;&lt;/div&gt;
      &lt;/div&gt;
      &lt;?php endif; ?&gt;
  &lt;/li&gt;
  &lt;?php endforeach; ?&gt;
  </code></pre>