3v4l.org

run code in 300+ PHP versions simultaneously
<?php $matrix = [ [0, 1, 2], [3, 4, 5], [6, 7, 8], [9, 10, 11], ]; /* i from to i/col i%col i&col i/rows 0 = [0][0] => [0][0] 0 0 0 0 1 = [0][1] => [1][0] 0.3 1 1 0.25 2 = [0][2] => [2][0] 0.6 2 2 0.5 3 = [1][0] => [3][0] 1 0 3 0.75 4 = [1][1] => [0][1] 1.3 1 0 1 5 = [1][2] => [1][1] 1.6 2 1 1.25 6 = [2][0] => [2][1] 2 0 2 1.5 7 = [2][1] => [3][1] 2.3 1 3 1.75 8 = [2][2] => [0][2] 2.6 2 0 2 9 = [3][0] => [1][2] 3 0 1 2.25 10 = [3][1] => [2][2] 3.3 1 2 2.5 11 = [3][2] => [3][2] 3.6 2 3 2.75 */ $rows = count($matrix); $cols = count(current($matrix)); $cells = $rows * $cols; $result = $matrix; for ($i = 0; $i < $cells; ++$i) { $result[$i % $rows][$i / $rows] = $matrix[$i / $cols][$i % $cols]; } var_export($result);

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.00.0130.00820.04
8.4.150.0020.00014.05
8.4.140.0080.01417.40
8.4.130.0140.00717.82
8.4.120.0020.00720.70
8.4.110.0040.00522.36
8.4.100.0080.00518.67
8.4.90.0040.00718.78
8.4.80.0140.00620.45
8.4.70.0090.01118.19
8.4.60.0100.00818.87
8.4.50.0080.00918.80
8.4.40.0070.01317.55
8.4.30.0080.00318.61
8.4.20.0090.00018.20
8.4.10.0030.00721.36
8.3.280.0130.00818.35
8.3.270.0130.00716.65
8.3.260.0100.00917.08
8.3.250.0090.01018.96
8.3.240.0130.00716.95
8.3.230.0110.00916.74
8.3.220.0090.00818.85
8.3.210.0090.00918.69
8.3.200.0060.00616.71
8.3.190.0130.00717.02
8.3.180.0090.00616.85
8.3.170.0030.00618.86
8.3.160.0090.00917.05
8.3.150.0100.01018.54
8.3.140.0120.00617.19
8.3.130.0080.00016.54
8.3.120.0100.00718.80
8.3.110.0090.00620.94
8.3.100.0000.01016.99
8.3.90.0030.00626.77
8.3.80.0030.00619.36
8.3.70.0090.01218.68
8.3.60.0120.00618.33
8.3.50.0060.01424.54
8.3.40.0140.00321.84
8.3.30.0090.01218.66
8.3.20.0070.00024.18
8.3.10.0080.00024.66
8.3.00.0080.00026.16
8.2.290.0110.00820.52
8.2.280.0210.00618.48
8.2.270.0090.00917.41
8.2.260.0040.00418.39
8.2.250.0040.00416.54
8.2.240.0000.00817.33
8.2.230.0040.00722.58
8.2.220.0080.00024.06
8.2.210.0070.00726.77
8.2.200.0030.00618.88
8.2.190.0090.01216.67
8.2.180.0120.00625.92
8.2.170.0090.00618.95
8.2.160.0030.01722.96
8.2.150.0040.00425.66
8.2.140.0040.00424.66
8.2.130.0040.00426.16
8.2.120.0050.00320.96
8.2.110.0150.00622.10
8.2.100.0080.00318.03
8.2.90.0000.00817.97
8.2.80.0100.00317.97
8.2.70.0000.00917.61
8.2.60.0040.00417.50
8.2.50.0000.00818.10
8.2.40.0120.00019.37
8.2.30.0040.00419.37
8.2.20.0050.00318.13
8.2.10.0040.00419.25
8.2.00.0050.00219.29
8.1.330.0150.00421.86
8.1.320.0120.00916.13
8.1.310.0140.00318.51
8.1.300.0040.00416.56
8.1.290.0040.00730.84
8.1.280.0160.00625.92
8.1.270.0030.00523.99
8.1.260.0070.00026.35
8.1.250.0000.00828.09
8.1.240.0080.00020.91
8.1.230.0110.00020.91
8.1.220.0080.00018.68
8.1.210.0080.00019.01
8.1.200.0060.00317.35
8.1.190.0040.00417.35
8.1.180.0040.00418.10
8.1.170.0050.00318.48
8.1.160.0040.00418.97
8.1.150.0040.00418.76
8.1.140.0050.00218.88
8.1.130.0030.00320.11
8.1.120.0000.00817.43
8.1.110.0000.00817.50
8.1.100.0000.00717.34
8.1.90.0040.00417.34
8.1.80.0040.00417.38
8.1.70.0000.00717.28
8.1.60.0090.00017.58
8.1.50.0110.00017.54
8.1.40.0060.00617.45
8.1.30.0000.00917.61
8.1.20.0060.00317.70
8.1.10.0050.00317.57
8.1.00.0040.00417.46
8.0.300.0050.00219.97
8.0.290.0060.00317.15
8.0.280.0000.00818.46
8.0.270.0040.00416.69
8.0.260.0030.00318.48
8.0.250.0000.00716.96
8.0.240.0000.00817.02
8.0.230.0040.00416.92
8.0.220.0000.00716.83
8.0.210.0000.00816.85
8.0.200.0000.00716.91
8.0.190.0000.00716.94
8.0.180.0000.00816.93
8.0.170.0030.00616.96
8.0.160.0040.00416.79
8.0.150.0000.00916.90
8.0.140.0070.00016.79
8.0.130.0030.00313.32
8.0.120.0070.00016.85
8.0.110.0000.00816.77
8.0.100.0030.00616.93
8.0.90.0030.00317.00
8.0.80.0090.00816.91
8.0.70.0000.00716.88
8.0.60.0080.00016.78
8.0.50.0050.00216.73
8.0.30.0100.00717.09
8.0.20.0100.01117.20
8.0.10.0000.00716.97
8.0.00.0040.01516.61
7.4.330.0020.00215.55
7.4.320.0030.00316.50
7.4.300.0030.00316.50
7.4.290.0000.00716.57
7.4.280.0000.00816.45
7.4.270.0030.00316.64
7.4.260.0030.00313.26
7.4.250.0040.00416.46
7.4.240.0050.00216.55
7.4.230.0040.00416.67
7.4.220.0050.00216.68
7.4.210.0080.00816.57
7.4.200.0040.00416.67
7.4.130.0150.00416.23
7.4.120.0140.00716.49
7.4.110.0170.00316.39
7.4.100.0210.00016.43
7.4.90.0170.00316.20
7.4.80.0110.00716.59
7.4.70.0150.00616.35
7.4.60.0130.00716.44
7.4.50.0120.00916.29
7.4.40.0130.00916.54
7.4.30.0070.01416.31
7.4.20.0120.00916.34
7.4.10.0150.00916.56
7.4.00.0150.00316.43
7.3.330.0000.00816.13
7.3.320.0000.00613.19
7.3.310.0070.00016.24
7.3.300.0060.00016.28
7.3.290.0040.00416.38
7.3.260.0090.00816.38
7.3.250.0120.00616.42
7.3.240.0090.00916.27
7.3.230.0080.01216.50
7.3.220.0130.00716.50
7.3.210.0070.01016.52
7.3.200.0190.00016.30
7.3.190.0230.00016.43
7.3.180.0080.01516.42
7.3.170.0190.00016.31
7.3.160.0130.00616.14
7.3.150.0080.01216.27
7.3.140.0120.00816.18
7.3.130.0130.00716.06
7.3.120.0100.01216.21
7.3.110.0030.01716.33
7.3.100.0170.00316.32
7.3.90.0090.01216.26
7.3.80.0100.01016.32
7.3.70.0100.00716.30
7.3.60.0140.00516.40
7.3.50.0140.00716.15
7.3.40.0140.00716.09
7.3.30.0160.00416.16
7.3.20.0250.00616.25
7.3.10.0380.00916.05
7.3.00.0170.00316.23

preferences:
28.29 ms | 403 KiB | 5 Q