title: PHP Get number of Sat&Sun for each month between two dates
body: <h2>What I am Trying</h2>
  
  <p>I am able to get the number of sat&amp;sun between two dates. What I want is to get the number of sat&amp;sun for each month between those dates. </p>
  
  <p>Suppose start_date is 4-Jul-2015 and end_date is 30-Aug-2015. Then there is 8 sat&amp;sun in Jul and 10 in Aug.</p>
  
  <p>From what I did I'm getting 18. But I need to get 8 and 10. How can I get this
  ?</p>
  
  <h2>Code</h2>
  
  <pre><code>$countSat = 0;
  $countSun = 0;
  $start = new DateTime($_POST['start']);
  $end   = new DateTime($_POST['end']);
  $interval = DateInterval::createFromDateString('1 day');
  $period = new DatePeriod($start, $interval, $end);
  foreach ($period as $dt)
   {
    if ($dt-&gt;format('N') == 7)
    {
      $countSun++;
    }
    if ($dt-&gt;format('N') == 6)
    {
      $countSat++;
    }
  }
  $count = $countSat + $countSun;
  </code></pre>