title: PHP Nested Loop
body: <p>PHP novice here. I would like to ask for a bit of help with my nested loop. I think I'm close but I'm pretty sure what I'm missing is a switch or a break or both. I've messed with this for a while but I just cant get it right. Here is the code example.</p>
  
  <pre><code>&lt;?php $items=array(thing01,thing02,thing03,thing04,thing05,thing06,thing07,thing08,thing09,thing10,thing11,thing12,thing13,thing14,thing15,thing16,thing17,thing18,thing19,thing20,thing21,thing22,thing23,thing24,thing25,thing26,thing27,thing28,thing29,thing30,thing31,thing32); ?&gt;
  &lt;?php $array_count = count($items); ?&gt;
  &lt;?php $item_count = 9; ?&gt;
  &lt;?php $blk_Number = ceil( $array_count / $item_count); ?&gt;
  &lt;?php echo "&lt;h3&gt;This list should contain " . $array_count . " items&lt;/h3&gt;"; ?&gt;
  &lt;ul&gt;
  &lt;?php
  for ($pas_Number = 1; $pas_Number &lt;= $blk_Number; $pas_Number++) {print "&lt;h3&gt;Start of Block " . $pas_Number . " of 9         items&lt;/h3&gt;";
  for ($key_Number = 0; $key_Number &lt; $item_count; $key_Number++){print "&lt;li&gt;" . $items[$key_Number] . "&lt;/li&gt;"; }
  {print "&lt;h3&gt;End of Block " . $pas_Number . " of 9 items&lt;/h3&gt;"; }
  }
  ; ?&gt;
  &lt;/ul&gt;
  </code></pre>
  
  <p>This is giving me the output of: </p>
  
  <p>This list should contain 32 items</p>
  
  <pre><code>Start of Block 1 of 9 items
  thing01
  thing02
  thing03
  thing04
  thing05
  thing06
  thing07
  thing08
  thing09
  End of Block 1 of 9 items
  Start of Block 2 of 9 items
  thing01
  thing02
  thing03
  thing04
  thing05
  thing06
  thing07
  thing08
  thing09
  End of Block 2 of 9 items
  Start of Block 3 of 9 items
  thing01
  thing02
  thing03
  thing04
  thing05
  thing06
  thing07
  thing08
  thing09
  End of Block 3 of 9 items
  Start of Block 4 of 9 items
  thing01
  thing02
  thing03
  thing04
  thing05
  thing06
  thing07
  thing08
  thing09
  Start of Block 4 of 9 items
  thing01
  thing02
  thing03
  thing04
  thing05
  thing06
  thing07
  thing08
  thing09
  End of Block 4 of 9 items
  </code></pre>
  
  <p>As you can see the count of the Array elements is wrong. Block 2 should contain things 10-18, Block 3 should contain things 19-27, and Block 4 should contain the remaining 5 "things". I apologize about all of the silly elements in the array, but I wanted to be able to clearly explain what I'm trying to do.</p>