title: Remove weekends from date range
body: <p>I'm using <a href="https://stackoverflow.com/a/28848503/609630">this answer</a> to help me but need to work it into my question.</p>
  <p>I want to count the days between two dates but then remove the weekends. How can I combine the following two answers?</p>
  <p>Date 1 is 06.10.2017 and date 2 is 09.10.2017.</p>
  <pre><code>$date1 = new DateTime(get_sub_field('start_date'));
  $date2 = new DateTime(get_sub_field('end_date'));
  
  $diff = $date2-&gt;diff($date1)-&gt;format(&quot;%a&quot;);
  echo $diff;
  </code></pre>
  <p>That gives 3 days. I want it to show 1 as there's a weekend in there. So I need to combine it with the following:</p>
  <p>This next answer removes all weekends:</p>
  <pre><code>function countDays($year, $month, $ignore) {
      $count = 0;
      $counter = mktime(0, 0, 0, $month, 1, $year);
      while (date(&quot;n&quot;, $counter) == $month) {
          if (in_array(date(&quot;w&quot;, $counter), $ignore) == false) {
              $count++;
          }
          $counter = strtotime(&quot;+1 day&quot;, $counter);
      }
      return $count;
  }
  echo countDays(2017, 10, array(0, 6)); // 22
  </code></pre>
  <p>Giving 22 business days in Oct.</p>
  <p><strong>How can I combine the two answers to show me a count of days between two dates but removing weekends?</strong></p>