3v4l.org

run code in 300+ PHP versions simultaneously
<?php $x = 1; // Start $y = 10; // Iterations Needed $days = []; //Empty Array while($x <= $y) { // Set Buffer $buffer = 2 + $x; // Get Date with Buffer $date = date(strtotime("+$buffer days")); // If the day is a weeday if(date('N', $date) < 6){ // Add to array $days[$date] = date("l, jS M", $date); // If not, increase max iteration (example: 10 to 11) }else{ $y++; } // Go to next loop $x++; } echo "<pre>"; print_r($days);

preferences:
53.7 ms | 402 KiB | 5 Q