Small and simple method to figure out weekends in a date interval and get the remaining

function getWorkingDays($nb_days, $from, $to)
{
    $wed = 0; // Week-end days

    // There's 2 week-end days for every 7 days
    while ($nb_days >= 7) {
        $wed += 2;
        $nb_days -= 7;
    }

    // Anything left ?
    if ($nb_days > 0) {
        $dow = date('N', strtotime($from)); // Day of week (Monday = 1, Sunday = 7)

        for ($i=0;$i<$nb_days;$i++) {
            if (in_array($dow, array(6, 7))) { // Current day is a week-end day
                $wed++;
            }

            // Day of week for next day
            ($dow == 7) && $dow = 0;
            $dow++;
        }
    }

    return $nb_days - $wed;
}