title: PHP While Loop dealing with last item in loop
body: <p>I have the following code:</p>
  
  <pre><code>$query6 = "SELECT TIMESTAMP As sDate, COUNT( TIMESTAMP ) AS Total 
             FROM tresults GROUP BY TO_DAYS( timestamp ) ";
  
  $result6 = $mysqli-&gt;query($query6);
  
  while($row6 = $result6-&gt;fetch_row())
      {
          $dt = new DateTime($row6[0]);
          $sd = $dt-&gt;format('M j');
  
          echo "['".$sd."',  ".$row6[1]."],";
  
      }
  </code></pre>
  
  <p>This works fine, but what I am struggling with is that I need the <code>echo</code> to be different the for the last one in the loop.  It needs to be (the comma is missing after the <code>]</code> for reference):</p>
  
  <pre><code>    echo "['".$sd."',  ".$row6[1]."]";  
  </code></pre>
  
  <p>I've been trying to do a count of the number of arrays but cannot get that to work.  Any suggestions welcomed.</p>