Add two business days to a date array excluding holiday dates

Viewed 1776

I am trying to add 2 weekdays to a date, but I also want to exclude the days in an array.

array of dates to exclude:

$bankHolidays = array();
foreach($obj as $e) {
    if($e->division == 'england-and-wales') {
        foreach($e->events as $events) {
            $bankHolidays[] = $events->date;
        }
    }
}

Adding 2 working days to date

$ret = date('d-m-Y', strtotime($bill["charge_customer_at"]. ' +2 weekdays'));

How can I include the array of dates to exclude?

As an example, if my date was 2017-07-19 and i want to add 2 week days, that would output 2017-07-21.

But if 2017-07-21 was in my array, it should skip this date and continue adding 2 weekdays so the output would end up being 2017-07-24 because of the weekend as well.

2 Answers
Related