3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr = [ [15, 16, 8, 1], [2, 3, 4, 7], [9, 11, 19, 6] ]; $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.70.0100.01318.30
8.3.60.0090.00917.50
8.3.50.0170.00321.99
8.3.40.0120.00619.66
8.3.30.0130.00319.68
8.3.20.0170.00321.21
8.3.10.0080.00023.46
8.3.00.0030.00719.79
8.2.190.0210.00017.50
8.2.180.0090.00917.25
8.2.170.0040.01322.96
8.2.160.0100.00621.41
8.2.150.0060.00324.18
8.2.140.0040.00424.66
8.2.130.0040.00721.04
8.2.120.0090.00026.35
8.2.110.0040.00720.14
8.2.100.0130.00018.90
8.2.90.0050.00520.08
8.2.80.0030.00618.50
8.2.70.0030.00718.63
8.2.60.0090.00018.79
8.2.50.0030.00618.63
8.2.40.0000.00821.01
8.2.30.0060.00321.59
8.2.20.0060.00318.64
8.2.10.0090.00019.06
8.2.00.0070.00319.13
8.1.280.0070.01425.92
8.1.270.0040.00720.02
8.1.260.0030.00628.09
8.1.250.0090.00028.09
8.1.240.0070.00423.44
8.1.230.0070.00719.16
8.1.220.0000.00918.89
8.1.210.0060.00318.77
8.1.200.0060.00618.50
8.1.190.0030.00618.60
8.1.180.0060.00318.91
8.1.170.0030.00919.71
8.1.160.0000.00922.18
8.1.150.0030.00620.16
8.1.140.0030.00620.81
8.1.130.0060.00318.94
8.1.120.0050.00518.84
8.1.110.0030.00618.85
8.1.100.0090.00018.74
8.1.90.0070.00719.15
8.1.80.0060.00318.70
8.1.70.0000.00818.73
8.1.60.0030.01018.84
8.1.50.0050.00518.92
8.1.40.0030.00618.79
8.1.30.0060.00318.86
8.1.20.0040.00418.93
8.1.10.0030.00618.87
8.1.00.0070.00318.71
8.0.300.0000.00918.77
8.0.290.0030.00617.88
8.0.280.0000.00919.60
8.0.270.0040.00418.50
8.0.260.0040.00419.68
8.0.250.0000.00918.35
8.0.240.0030.00518.19
8.0.230.0030.00618.21
8.0.220.0040.00418.23
8.0.210.0000.00918.15
8.0.200.0060.00318.19
8.0.190.0000.00918.21
8.0.180.0030.00618.20
8.0.170.0030.00718.22
8.0.160.0090.00018.20
8.0.150.0070.00318.15
8.0.140.0030.00618.13
8.0.130.0040.00414.70
8.0.120.0030.00618.20
8.0.110.0040.00418.04
8.0.100.0030.00618.11
8.0.90.0060.00317.98
8.0.80.0100.01018.14
8.0.70.0050.00518.09
8.0.60.0060.00318.13
8.0.50.0030.00618.08
8.0.30.0160.00718.39
8.0.20.0170.01418.49
8.0.10.0030.00618.24
8.0.00.0160.01118.11
7.4.330.0000.00916.19
7.4.320.0030.00617.77
7.4.300.0030.00517.84
7.4.290.0120.00017.84
7.4.280.0070.00317.69
7.4.270.0030.00617.68
7.4.260.0060.00617.65
7.4.250.0060.00317.66
7.4.240.0030.00617.69
7.4.230.0060.00317.77
7.4.220.0140.01417.62
7.4.210.0030.01517.77
7.4.200.0030.00717.78
7.4.160.0130.00917.64
7.4.150.0120.01917.70
7.4.140.0150.01417.86
7.4.130.0170.00917.81
7.4.120.0150.01317.83
7.4.110.0130.02317.83
7.4.100.0180.01517.66
7.4.90.0100.01317.80
7.4.80.0090.01819.39
7.4.70.0090.01217.82
7.4.60.0130.00917.75
7.4.50.0100.00617.52
7.4.40.0120.00917.83
7.4.30.0150.01117.61
7.4.00.0090.00916.18
7.3.330.0690.156137.20
7.3.320.0370.132137.06
7.3.310.0090.00017.63
7.3.300.0000.01017.53
7.3.290.0110.01217.57
7.3.280.0120.01417.79
7.3.270.0190.00817.77
7.3.260.0160.01617.61
7.3.250.0120.01617.68
7.3.240.0110.01317.67
7.3.230.0090.01617.85
7.3.210.0140.01117.74
7.3.200.0060.02117.58
7.3.190.0100.01317.67
7.3.180.0080.01617.81
7.3.170.0030.02117.54
7.3.160.0160.00917.52
7.2.330.0240.00617.97
7.2.320.0100.01618.02
7.2.310.0110.01417.93
7.2.300.0200.01717.79
7.2.290.0100.01718.00
7.2.60.0060.00616.98
7.2.00.0160.01018.84
7.1.200.0100.00615.82
7.1.100.0310.00417.60
7.1.70.0000.01517.04
7.1.60.0070.01719.13
7.1.50.0040.00917.21
7.1.00.0130.07322.28
7.0.200.0000.01116.82
7.0.60.0030.08321.42
7.0.50.0130.06319.17
7.0.40.0070.07319.92
7.0.30.0370.07320.00
7.0.20.0270.06319.93
7.0.10.0030.04319.77
7.0.00.0070.05719.95
5.6.280.0000.04023.21
5.6.210.0230.07322.88
5.6.200.0030.08720.31
5.6.190.0000.10022.53
5.6.180.0370.04322.45
5.6.170.0230.04022.48
5.6.160.0070.08022.51
5.6.150.0170.03020.27
5.6.140.0170.04020.39
5.6.130.0100.09020.14
5.6.120.0130.08023.15
5.6.110.0100.09023.13
5.6.100.0000.09323.17
5.6.90.0200.08023.04
5.6.80.0070.08022.64
5.5.350.0030.05722.62
5.5.340.0030.04320.14
5.5.330.0100.07722.15
5.5.320.0070.05722.38
5.5.310.0430.08022.51
5.5.300.0030.04720.04
5.5.290.0030.07020.14
5.5.280.0230.07322.95
5.5.270.0100.04723.01
5.5.260.0170.08022.88
5.5.250.0030.07722.73
5.5.240.0070.08722.31

preferences:
31.17 ms | 401 KiB | 5 Q