title: Limit PHP foreach Results
body: <p>I have a section in my footer from a script, that I am trying to customize and that displays the website categories. </p>
  
  <p>Currently the results were limited to 9 results per column and continuing onto x amounts of columns. I need to be able to stop at 2 columns.</p>
  
  <p>Here is the code I have</p>
  
  <pre><code>&lt;div class="left"&gt;
      &lt;h3 style="padding-top:15px;"&gt;&lt;?php echo BROWSE_CATEGORIES; ?&gt;&lt;/h3&gt;
      &lt;?php $footer_category= $this-&gt;home_model-&gt;get_category(); ?&gt;
      &lt;?php if($footer_category) { $ftr_cnt=1; ?&gt;
      &lt;ul&gt;
          &lt;?php foreach($footer_category as $cat) { 
              echo '&lt;li&gt;'.anchor('search/category/'.$cat-&gt;project_category_id,substr($cat-&gt;project_category_name,0,30)).'&lt;/li&gt;'; 
  
              if($ftr_cnt&gt;9) { $ftr_cnt=1; echo "&lt;/ul&gt;&lt;ul&gt;";  }
                  $ftr_cnt++;
              }
          } ?&gt;
      &lt;/ul&gt;
  &lt;/div&gt;
  </code></pre>