3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr = [ [15, 16, 8, 1], [2, 3, 4, 7], [9, 11, 19, 6] ]; global $sortedArr; function bubbleSortRowCol($arr) { $colCount = 0; $tempArr = []; $columnArr = []; foreach($arr as $key => $row) { $tempArr[$key] = bubbleSort($row); $colCount = count($row); } for($i = 0; $i < $colCount; $i++) { $columnArr[] = bubbleSort(array_column($arr, $i)); } if($columnArr !== $sortedArr) { bubbleSortRowCol($columnArr); } return $tempArr; } function fullSortArr($arr) { $fullArr = []; $tempArr = []; $countArr = []; $n = 0; foreach($arr as $value) { $fullArr = array_merge($fullArr, $value); $countArr[] = count($value); } asort($fullArr); foreach($countArr as $key => $length) { $tempArr[] = array_slice($fullArr, $n, $length); $n += $length; } return $tempArr; } function bubbleSort($arr) { $sorted = false; while (false === $sorted) { $sorted = true; for ($i = 0; $i < count($arr) - 1; $i++) { $current = $arr[$i]; $next = $arr[$i + 1]; if ($next < $current) { $arr[$i] = $next; $arr[$i + 1] = $current; $sorted = false; } } } return $arr; } $sortedArr = fullSortArr($arr); print_r(bubbleSortRowCol($arr));

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.3.60.0000.01617.75
8.3.50.0040.01218.05
8.3.40.0100.00719.55
8.3.30.0110.00719.71
8.3.20.0090.00021.06
8.3.10.0040.00423.66
8.3.00.0090.00019.91
8.2.180.0160.00717.63
8.2.170.0030.01422.96
8.2.160.0140.00721.39
8.2.150.0030.00624.18
8.2.140.0060.00324.66
8.2.130.0060.00320.94
8.2.120.0070.00326.35
8.2.110.0060.00621.20
8.2.100.0070.00719.04
8.2.90.0060.00320.09
8.2.80.0050.00518.50
8.2.70.0000.01018.50
8.2.60.0000.01119.04
8.2.50.0090.00018.63
8.2.40.0000.00921.09
8.2.30.0080.00021.69
8.2.20.0090.00018.82
8.2.10.0050.00519.08
8.2.00.0030.00619.16
8.1.280.0130.00325.92
8.1.270.0100.00020.17
8.1.260.0090.00028.09
8.1.250.0060.00328.09
8.1.240.0070.00423.39
8.1.230.0030.01019.03
8.1.220.0050.00519.03
8.1.210.0030.00618.77
8.1.200.0040.00718.72
8.1.190.0060.00318.60
8.1.180.0060.00318.42
8.1.170.0060.00319.68
8.1.160.0060.00322.10
8.1.150.0040.00420.25
8.1.140.0060.00320.81
8.1.130.0040.00820.97
8.1.120.0050.00518.75
8.1.110.0060.00318.82
8.1.100.0030.00718.84
8.1.90.0030.00918.80
8.1.80.0000.00818.77
8.1.70.0030.00618.71
8.1.60.0030.00918.98
8.1.50.0030.00718.80
8.1.40.0040.00718.84
8.1.30.0100.00018.95
8.1.20.0030.00618.96
8.1.10.0060.00318.96
8.1.00.0050.00518.80
8.0.300.0060.00318.77
8.0.290.0030.00717.88
8.0.280.0030.00719.68
8.0.270.0030.00518.50
8.0.260.0080.00418.13
8.0.250.0030.00518.29
8.0.240.0060.00318.23
8.0.230.0030.00618.24
8.0.220.0040.00418.17
8.0.210.0040.00418.21
8.0.200.0080.00018.06
8.0.190.0090.00018.28
8.0.180.0030.00718.22
8.0.170.0050.00518.15
8.0.160.0030.00618.25
8.0.150.0060.00618.13
8.0.140.0030.00618.13
8.0.130.0040.00414.70
8.0.120.0050.00518.19
8.0.110.0070.00317.98
8.0.100.0030.00618.17
8.0.90.0000.00917.99
8.0.80.0030.02018.83
8.0.70.0060.00318.15
8.0.60.0060.00318.08
8.0.50.0030.00618.00
8.0.30.0130.01118.37
8.0.20.0150.01118.26
8.0.10.0050.00518.30
8.0.00.0160.00917.93
7.4.330.0060.00316.36
7.4.320.0030.00617.69
7.4.300.0000.00817.71
7.4.290.0030.00617.76
7.4.280.0040.00717.68
7.4.270.0000.01017.69
7.4.260.0060.00817.70
7.4.250.0050.00517.69
7.4.240.0030.00617.73
7.4.230.0060.00317.78
7.4.220.0140.01417.89
7.4.210.0080.01117.76
7.4.200.0060.00317.55
7.4.160.0110.01817.86
7.4.150.0130.01617.78
7.4.140.0130.01517.90
7.4.130.0210.00717.75
7.4.120.0160.01017.79
7.4.110.0240.01217.77
7.4.100.0100.01317.83
7.4.90.0190.00917.64
7.4.80.0080.02319.39
7.4.70.0120.01217.70
7.4.60.0080.01817.74
7.4.50.0030.01017.73
7.4.40.0160.01617.59
7.4.30.0110.02117.65
7.4.00.0070.01415.82
7.3.330.0600.139137.14
7.3.320.0440.124137.18
7.3.310.0060.00317.66
7.3.300.0030.00717.46
7.3.290.0110.00917.60
7.3.280.0170.00717.80
7.3.270.0180.00717.62
7.3.260.0220.00317.73
7.3.250.0140.01317.66
7.3.240.0190.01217.82
7.3.230.0210.00717.84
7.3.210.0210.00617.58
7.3.200.0070.01417.60
7.3.190.0220.00017.63
7.3.180.0120.02118.30
7.3.170.0060.01917.57
7.3.160.0090.01517.62
7.2.330.0150.01217.96
7.2.320.0060.02017.81
7.2.310.0170.00917.77
7.2.300.0200.01417.76
7.2.290.0070.01817.59
7.2.60.0090.00616.86
7.2.00.0090.00918.97
7.1.200.0130.00415.95
7.1.100.0400.01117.94
7.1.70.0060.00317.04
7.1.60.0030.02419.13
7.1.50.0030.00917.20
7.1.00.0070.07722.22
7.0.200.0000.01016.91
7.0.60.0000.05021.30
7.0.50.0100.07719.13
7.0.40.0170.07719.93
7.0.30.0230.08319.89
7.0.20.0200.07320.02
7.0.10.0030.04319.76
7.0.00.0070.05319.86
5.6.210.0270.06322.92
5.6.200.0030.06020.40
5.6.190.0100.06722.51
5.6.180.0330.04722.55
5.6.170.0200.04322.57
5.6.160.0130.08022.47
5.6.150.0100.04020.30
5.6.140.0070.08320.29
5.6.130.0130.09320.31
5.6.120.0170.07023.27
5.6.110.0170.06023.27
5.6.100.0130.09323.15
5.6.90.0130.08323.18
5.6.80.0100.05022.53
5.5.350.0030.04722.54
5.5.340.0100.03720.12
5.5.330.0070.09322.32
5.5.320.0430.08322.29
5.5.310.0330.06722.27
5.5.300.0030.04720.09
5.5.290.0100.08320.12
5.5.280.0130.08323.02
5.5.270.0100.08323.00
5.5.260.0100.09322.94
5.5.250.0100.05722.73
5.5.240.0100.09022.20

preferences:
51.1 ms | 400 KiB | 5 Q