3v4l.org

run code in 500+ PHP versions simultaneously
<?php /* ------------------ */ $server_seed = ""; $round = ""; $number_of_tickets = 0; /* ------------------ */ if ($server_seed == '' || $round == '' || $number_of_tickets == 0) { echo "Fill in details"; return; } // Create HMAC-SHA256 hash $hash = hash_hmac('sha256', (string)$round, $server_seed); // Convert hex to decimal using bcmath $decimal_hash = '0'; $length = strlen($hash); for ($i = 0; $i < $length; $i++) { $decimal_hash = bcmul($decimal_hash, '16'); $decimal_hash = bcadd($decimal_hash, (string)hexdec($hash[$i])); } // Apply modulo to get the winning position $roll = bcmod($decimal_hash, (string)$number_of_tickets); echo "Winning ticket position: $roll\n"; ?>

Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).

VersionSystem time (s)User time (s)Memory (MiB)
8.5.80.0100.00816.86
8.5.70.0070.00716.72
8.5.60.0200.00616.73
8.5.50.0350.00516.51
8.5.40.0200.00516.32
8.5.30.0390.00516.48
8.5.20.0230.00516.44
8.5.10.0320.00916.32
8.5.00.0110.00816.81
8.4.230.0110.01019.50
8.4.220.0050.01125.73
8.4.210.0130.00719.44
8.4.200.0270.00419.47
8.4.190.0300.00919.45
8.4.180.0310.00919.67
8.4.170.0140.00719.62
8.4.160.0160.00419.69
8.4.150.0180.00419.60
8.4.140.0160.00317.48
8.4.130.0150.00617.49
8.4.120.0110.00617.59
8.4.110.0150.00417.68
8.4.100.0200.00317.72
8.4.90.0150.00417.57
8.4.80.0180.00317.43
8.4.70.0250.00817.55
8.4.60.0190.01217.67
8.4.50.0220.00817.53
8.4.40.0200.00317.32
8.4.30.0160.00517.59
8.4.20.0160.00517.64
8.4.10.0170.00317.60
8.3.320.0110.01318.41
8.3.310.0120.00418.36
8.3.300.0160.00418.02
8.3.290.0160.00218.05
8.3.280.0180.00618.41
8.3.270.0170.00316.52
8.3.260.0160.00416.37
8.3.250.0170.00316.26
8.3.240.0150.00316.36
8.3.230.0170.00116.64
8.3.220.0140.00516.38
8.3.210.0140.00416.56
8.3.200.0130.00516.57
8.3.190.0170.00516.47
8.3.180.0120.00616.64
8.3.170.0220.00616.40
8.3.160.0190.00316.42
8.3.150.0180.00216.41
8.3.140.0170.00416.73
8.3.130.0130.00516.48
8.3.120.0120.00516.49
8.3.110.0150.00316.39
8.3.100.0140.00616.66
8.3.90.0150.00416.45
8.3.80.0170.00316.74
8.3.70.0120.00716.54
8.3.60.0170.00316.66
8.3.50.0120.00716.66
8.3.40.0170.00317.64
8.3.30.0140.00317.77
8.3.20.0100.00817.70
8.3.10.0110.00617.71
8.3.00.0120.00217.70
8.2.320.0110.00818.12
8.2.310.0120.00717.79

preferences:
42.56 ms | 762 KiB | 5 Q