title: PHP for each Loop return only certain elements
body: <p>I am using an API from Bittrex , reading the json and then looping through with a for each loop to get the info i need</p>
  
  <p>everything is working correctly.  and here is the code :</p>
  
  <pre><code>     foreach($return[result] as $x=&gt;$x_value){
              extract($x_value);
              echo $OrderUuid." " .$closedDate ."  " .$closedTime ."    " .$Quantity."  " .$Price."  " . $PricePerUnit * 100000000 ." &lt;br&gt;";
         }
  </code></pre>
  
  <p>But, What I want to do because I am putting this into a table with pagination is I need to be able to only  echo out results like 1-5  then next page will be 6-11 and so on</p>
  
  <p>i know the count already  by using this and it returns the amount of results.  </p>
  
  <pre><code>$thisManyResults=count($return[result]);
  </code></pre>
  
  <p>I know i need to keep in mind that index starts at ZERO as well.</p>
  
  <p>Loops  confuse me so badly, please also give an explanation for a newbie to wrap his head around. Thank you</p>
  
  <p>EDIT:</p>
  
  <pre><code>foreach($return[result] as $x=&gt;$x_value){
      extract($x_value);
  
  
      $str66 = str_replace('T', ' ', $TimeStamp);
      $newarray = explode(" ", $str66);
      $date =date_create($newarray[0]);
      $closedDate = date_format($date,"m/d/Y");
      $closedTime = date("g:i:s a", strtotime($newarray[1]));
  
  
      // echo $OrderUuid."      " .$closedDate ."           " .$closedTime ."    " .$Quantity."      " .$Price."      " . $PricePerUnit * 100000000 ." &lt;br&gt;";
  
  
          echo "&lt;td style='text-decoration:none;color:#000000;font-weight:normal'&gt;". $Quantity ." &lt;/td&gt;";
          echo "&lt;td style='text-decoration:none;color:#000000;font-weight:normal'&gt;&lt;center&gt;". $Price." &lt;/center&gt;&lt;/td&gt;";
          echo "&lt;td style='text-decoration:none;color:#000000;font-weight:normal'&gt;&lt;center&gt;". $PricePerUnit * 100000000 ." &lt;/center&gt;&lt;/td&gt;";
          echo "&lt;td style='text-decoration:none;color:#000000;font-weight:normal'&gt;&lt;center&gt;". $closedDate." &lt;/center&gt;&lt;/td&gt;";
          echo "&lt;td style='text-decoration:none;color:#000000;font-weight:normal'&gt;&lt;center&gt;". $closedTime." &lt;/center&gt;&lt;/td&gt;&lt;/tr&gt;";
  
    }
  </code></pre>
  
  <p>but this shows ALL results  0-22 (23 results)   I need to be able to only show in table   0 thru 5   or 6 thru 10</p>