剩余的日子不包括周末

i just want to know how to get the remaining days excluding the weekends. i tried subtracting two dates but i cant seem to find any solutions on removing weekends. well this is my code:

            $date_registered = date('Y-m-d');
            $date_planned = $_POST['start_date'];
            $dueDate = $date_registered;
            $numDays = 3;
            $counter = 1;
            while ($counter <= $numDays) {

               $dueDate = date("Y-m-d", strtotime(date("Y-m-d", strtotime($dueDate)) . " +1 day"));
               $dayOfTheWeek = date("l",strtotime($dueDate));

            if ($dayOfTheWeek == "Saturday" || $dayOfTheWeek == "Sunday") {
                   continue;
               }else {
                  $counter++;
               }

            }
            echo $date_registered.'<br>';
            echo $date_planned.'<br>';
            //echo $dueDate;
            $remaining_days = strtotime($date_registered) - strtotime($date_planned);
            echo $remaining_days/86400;

i dont have any idea how to exclude the weekends .i hope you could help me.

Try this one

$date = date('Y-m-d'); 
$total_days_left = (strtotime($end_date) - strtotime($current_date)) / (60 * 60 * 24);
while (strtotime($date) <= strtotime($end_date)) {
  $timestamp = strtotime($date);  
  $day = date('D', $timestamp); 

  if($day=='Sat' || $day=='Sun') {
    $count++ ; 
  }
  $date = date ("Y-m-d", strtotime("+1 day", strtotime($date)));
}

Let me know if you face any issue. Count will provide the number of week end days falling between these two days.From that you can count remaining day easily.

$total_day_left_excluding_weekends = $total_days_left - $count;

Refer date and strtotime on official PHP site.

$time = $sTime = START_TIMESTAMP;
$eTime = END_TIMESTAMP;
$count = 0;

while(date('w', $time) != 0) {
    $time += 86400;
}

while($time < $eTime) {
    $count++;
    $time += 7 * 86400;
}