3v4l.org

run code in 300+ PHP versions simultaneously
<?php $types = array( "text" => 2, "image" => 3, "audio" => 2, ); $data = []; $keys = array_keys($types); $last = end($keys); while (list($type, $count) = @each($types)) { if ($count !== 0) { // push until count reaches zero $data[] = $type; // push it inside $types[$type]--; // subtract 1 count } if ($type === $last) { // if reached the end, reset the loop reset($types); } if (array_sum($types) === 0) { // end the loop if all are gone break; } } print_r($data); ?>

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.4.120.0110.01020.77
8.4.110.0040.00518.98
8.4.100.0080.00118.04
8.4.90.0090.01220.29
8.4.80.0110.00919.08
8.4.70.0050.00418.07
8.4.60.0110.00819.00
8.4.50.0130.00718.03
8.4.40.0030.00617.88
8.4.30.0130.00618.54
8.4.20.0060.00319.95
8.4.10.0170.00321.51
8.3.250.0020.00619.11
8.3.240.0100.01016.75
8.3.230.0120.00717.36
8.3.220.0120.00718.63
8.3.210.0100.01018.61
8.3.200.0040.00416.66
8.3.190.0130.00716.59
8.3.180.0090.00616.61
8.3.170.0110.00716.66
8.3.160.0070.01116.65
8.3.150.0070.00717.19
8.3.140.0000.00820.59
8.3.130.0040.00418.49
8.3.120.0030.00620.82
8.3.110.0060.00320.94
8.3.100.0060.00318.55
8.3.90.0100.01026.77
8.3.80.0060.00316.75
8.3.70.0110.00718.56
8.3.60.0130.00918.56
8.3.50.0220.01024.45
8.3.40.0140.00718.65
8.3.30.0060.00918.67
8.3.20.0040.00424.18
8.3.10.0040.01124.66
8.3.00.0070.00026.16
8.2.290.0120.00716.51
8.2.280.0130.00618.90
8.2.270.0060.01316.76
8.2.260.0080.00019.15
8.2.250.0060.01016.86
8.2.240.0120.00617.08
8.2.230.0040.00422.58
8.2.220.0040.00424.06
8.2.210.0090.00026.77
8.2.200.0040.00416.88
8.2.190.0180.00416.88
8.2.180.0110.00425.92
8.2.170.0150.00618.92
8.2.160.0090.00622.96
8.2.150.0040.00425.66
8.2.140.0140.00024.66
8.2.130.0160.00326.16
8.2.120.0000.00721.13
8.2.110.0060.00320.99
8.2.100.0080.00317.84
8.2.90.0040.00418.09
8.2.80.0080.00018.34
8.2.70.0000.00817.75
8.2.60.0040.00417.63
8.2.50.0040.00418.07
8.2.40.0080.00018.34
8.2.30.0000.00818.08
8.2.20.0090.00018.09
8.2.10.0040.00419.39
8.2.00.0000.00719.26
8.1.330.0130.00716.05
8.1.320.0120.00816.34
8.1.310.0000.00816.90
8.1.300.0090.00618.11
8.1.290.0040.00418.88
8.1.280.0140.00725.92
8.1.270.0170.00322.08
8.1.260.0040.00426.35
8.1.250.0080.00028.09
8.1.240.0060.00322.19
8.1.230.0090.00321.09
8.1.220.0080.00017.74
8.1.210.0060.00318.78
8.1.200.0030.00617.35
8.1.190.0000.00817.22
8.1.180.0030.00518.10
8.1.170.0040.00418.57
8.1.160.0000.00818.88
8.1.150.0000.00718.94
8.1.140.0000.00818.84
8.1.130.0000.00717.52
8.1.120.0060.00317.40
8.1.110.0040.00417.36
8.1.100.0070.00017.47
8.1.90.0000.00717.54
8.1.80.0030.00617.52
8.1.70.0030.00617.51
8.1.60.0030.00717.63
8.1.50.0030.00917.56
8.1.40.0040.00417.52
8.1.30.0000.00817.73
8.1.20.0000.00717.60
8.1.10.0040.00417.59
8.1.00.0070.00417.55
8.0.300.0070.00019.87
8.0.290.0070.00016.88
8.0.280.0030.00320.16
8.0.270.0070.00017.99
8.0.260.0070.00016.90
8.0.250.0070.00016.91
8.0.240.0030.00316.93
8.0.230.0030.00317.07
8.0.220.0030.00316.95
8.0.210.0040.00416.84
8.0.200.0030.00516.90
8.0.190.0000.00917.03
8.0.180.0050.00317.01
8.0.170.0060.00316.99
8.0.160.0070.00016.91
8.0.150.0070.00016.86
8.0.140.0000.00716.95
8.0.130.0030.00313.46
8.0.120.0040.00416.79
8.0.110.0050.00216.82
8.0.100.0050.00316.84
8.0.90.0040.00417.02
8.0.80.0080.01116.96
8.0.70.0000.00817.06
8.0.60.0040.00416.92
8.0.50.0050.00316.99
8.0.30.0070.01017.21
8.0.20.0120.00716.99
8.0.10.0000.00716.95
8.0.00.0090.00916.79
7.4.330.0000.00515.55
7.4.320.0060.00016.54
7.4.300.0020.00516.49
7.4.290.0040.00416.53
7.4.280.0040.00416.52
7.4.270.0040.00416.66
7.4.260.0030.00313.32
7.4.250.0070.00016.57
7.4.240.0050.00316.45
7.4.230.0030.00316.60
7.4.220.0020.00516.58
7.4.210.0080.00916.65
7.4.200.0030.00316.64
7.4.130.0140.00416.49
7.4.120.0130.00316.50
7.4.110.0090.00916.48
7.4.100.0100.00716.49
7.4.90.0030.01316.68
7.4.80.0130.00316.45
7.4.70.0080.00816.64
7.4.60.0060.01116.56
7.4.50.0070.01416.22
7.4.40.0090.00916.46
7.4.30.0160.00716.50
7.4.20.0060.01016.39
7.4.10.0160.00616.65
7.4.00.0160.00716.48
7.3.330.0070.00016.60
7.3.320.0000.00513.32
7.3.310.0030.00316.48
7.3.300.0030.00316.27
7.3.290.0060.00916.38
7.3.280.0060.00916.29
7.3.260.0100.00716.45
7.3.230.0090.00616.48
7.3.210.0060.00916.41
7.3.200.0070.01016.38
7.3.190.0160.00016.52
7.3.180.0130.00316.37
7.3.170.0140.00616.46
7.3.160.0100.01316.47
7.3.150.0070.01016.50
7.3.140.0100.00716.39
7.3.130.0100.00716.48
7.3.120.0130.01016.29
7.3.110.0110.01116.43
7.3.100.0030.01416.27
7.3.90.0120.00916.36
7.3.80.0180.00416.77
7.3.70.0100.01216.41
7.3.60.0140.00716.14
7.3.50.0070.01116.11
7.3.40.0060.01516.52
7.3.30.0030.01516.21
7.3.20.0360.01016.46
7.3.10.0120.00916.23
7.3.00.0120.00916.52
7.2.330.0190.00316.84
7.2.320.0100.00716.66
7.2.310.0110.00616.63
7.2.300.0070.01016.81
7.2.290.0100.01416.39
7.2.280.0060.01216.34
7.2.270.0070.01016.61
7.2.260.0120.00616.56
7.2.250.0100.01316.67
7.2.240.0150.00916.48
7.2.230.0090.00916.61
7.2.220.0100.01316.75
7.2.210.0150.00416.32
7.2.200.0090.00816.42
7.2.190.0100.00716.38
7.2.180.0140.00416.64
7.2.170.0000.01816.78
7.2.160.0090.01516.59
7.2.150.0150.00916.59
7.2.140.0090.00916.59
7.2.130.0090.00916.77
7.2.120.0130.01016.66
7.2.110.0070.01716.51
7.2.100.0030.01416.71
7.2.90.0030.01516.64
7.2.80.0070.01116.83
7.2.70.0070.01116.79
7.2.60.0150.00316.65
7.2.50.0090.00916.64
7.2.40.0070.01016.77
7.2.30.0150.00416.63
7.2.20.0070.01416.82
7.2.10.0040.01516.75
7.2.00.0100.01316.51

preferences:
27.21 ms | 403 KiB | 5 Q