3v4l.org

run code in 300+ PHP versions simultaneously
<?php /* the difference in days between today and '$delay' number business days (M-F). yes. */ function g($current_day, $delay) { /* wraps around to the next day which is '$delay' number of business days from today lol, math */ if(($current_day+$delay) > 5) return abs((7+(((min($current_day, 5)+($delay-1))%5)+1)) - $current_day); else return $delay; } function f($current_day, $delay) { return abs((7+(((min($current_day, 5)+($delay-1))%5)+1)) - $current_day); } for($i = 1; $i < 8; $i++) printf("\tf(%d, 1) => %d\n", $i, f($i, 1)); printf("\n\n\n\n"); for($i = 1; $i < 8; $i++) printf("\tf(%d, 2) => %d\n", $i, f($i, 2));

preferences:
32.51 ms | 402 KiB | 5 Q