3v4l.org

run code in 300+ PHP versions simultaneously
<?php $cars = array ( 0 => (object)(array( 'id' => 1, 'title' => 'Golf', 'manufacturer' => 1 )), 1 => (object)(array( 'id' => 2, 'title' => 'Focus', 'manufacturer' => 2 )), 2 => (object)(array( 'id' => 3, 'title' => 'Jazz', 'manufacturer' => null )), 3 => (object)(array( 'id' => 4, 'title' => 'Passat', 'manufacturer' => 1 )), 4 => (object)(array( 'id' => 5, 'title' => 'Toureg', 'manufacturer' => 1 )), 5 => (object)(array( 'id' => 6, 'title' => 'Galaxy', 'manufacturer' => 2 )), 6 => (object)(array( 'id' => 7, 'title' => 'Falcon', 'manufacturer' => null )), 7 => (object)(array( 'id' => 8, 'title' => 'Commodore', 'manufacturer' => null )), 8 => (object)(array( 'id' => 9, 'title' => 'Phoenix', 'manufacturer' => 3 )), 9 => (object)(array( 'id' => 10, 'title' => 'Cressida', 'manufacturer' => null )) ); // sort based on manufacturer usort($cars, function ($a, $b) { if (!$a->manufacturer) { // if both null, sort by id if (!$b->manufacturer) return $a->id - $b->id; // otherwise sort null values last return 1; } if (!$b->manufacturer) // sort null values last return -1; return $a->manufacturer - $b->manufacturer; }); $lastmfg = 0; foreach ($cars as $car) { if (!$car->manufacturer || $car->manufacturer != $lastmfg) { if ($lastmfg !== 0) echo "</div>\n"; echo '<div class="container'. ($car->manufacturer ? ' id' . $car->manufacturer : '') .'">'. "\n"; } echo 'ID: ' . $car->id . ' - ' . $car->title . "\n"; $lastmfg = $car->manufacturer; } echo "</div>\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.4.10.0000.00819.58
8.3.140.0110.00718.59
8.3.130.0090.00016.73
8.3.120.0100.00020.65
8.3.110.0060.00618.04
8.3.100.0090.00918.52
8.3.90.0080.00016.92
8.3.80.0110.00019.36
8.3.70.0070.01116.88
8.3.60.0090.00616.63
8.3.50.0090.00823.60
8.3.40.0100.00719.14
8.3.30.0070.00718.70
8.3.20.0040.00424.18
8.3.10.0050.00224.66
8.3.00.0040.00426.16
8.2.260.0100.00616.73
8.2.250.0060.00316.77
8.2.240.0030.00617.31
8.2.230.0080.00020.94
8.2.220.0000.00824.06
8.2.210.0060.00326.77
8.2.200.0100.00016.88
8.2.190.0170.00318.29
8.2.180.0090.00625.92
8.2.170.0080.00819.08
8.2.160.0140.00022.96
8.2.150.0040.00425.66
8.2.140.0040.00424.66
8.2.130.0040.00426.16
8.2.120.0040.00418.88
8.2.110.0060.00320.87
8.2.100.0080.00418.03
8.2.90.0000.00917.75
8.2.80.0030.00518.81
8.2.70.0000.00817.93
8.2.60.0000.00818.16
8.2.50.0090.00318.10
8.2.40.0000.00819.30
8.2.30.0070.00019.37
8.2.20.0070.00018.20
8.2.10.0000.00719.33
8.2.00.0020.00519.19
8.1.310.0080.00016.85
8.1.300.0060.00318.54
8.1.290.0070.00318.88
8.1.280.0140.00325.92
8.1.270.0040.00423.99
8.1.260.0080.00026.35
8.1.250.0040.00428.09
8.1.240.0080.00023.77
8.1.230.0030.01320.26
8.1.220.0040.00417.77
8.1.210.0060.00318.77
8.1.200.0040.00817.36
8.1.190.0030.00617.23
8.1.180.0030.00618.10
8.1.170.0050.00318.48
8.1.160.0070.00019.05
8.1.150.0070.00018.81
8.1.140.0000.00718.83
8.1.130.0000.00720.23
8.1.120.0030.00717.49
8.1.110.0030.00517.45
8.1.100.0040.00417.50
8.1.90.0000.00717.46
8.1.80.0000.00717.48
8.1.70.0040.00417.50
8.1.60.0030.00517.47
8.1.50.0040.00417.45
8.1.40.0030.00517.57
8.1.30.0050.00317.67
8.1.20.0040.00417.64
8.1.10.0080.00017.52
8.1.00.0000.00817.42
8.0.300.0000.00719.72
8.0.290.0040.00416.72
8.0.280.0070.00018.32
8.0.270.0000.00816.90
8.0.260.0000.00718.48
8.0.250.0110.00016.96
8.0.240.0080.00016.93
8.0.230.0000.00817.07
8.0.220.0040.00417.00
8.0.210.0040.00416.97
8.0.200.0000.00716.96
8.0.190.0000.00817.06
8.0.180.0050.00317.00
8.0.170.0000.00816.96
8.0.160.0040.00416.95
8.0.150.0040.00416.92
8.0.140.0040.00416.90
8.0.130.0000.00613.34
8.0.120.0040.00416.97
8.0.110.0030.00517.02
8.0.100.0040.00416.85
8.0.90.0040.00416.88
8.0.80.0090.00916.91
8.0.70.0000.00816.81
8.0.60.0040.00416.80
8.0.50.0040.00416.80
8.0.30.0070.01017.30
8.0.20.0120.00617.20
8.0.10.0030.00517.04
8.0.00.0100.01616.79
7.4.330.0030.00315.55
7.4.320.0040.00416.58
7.4.300.0060.00016.51
7.4.290.0050.00216.53
7.4.280.0090.00016.67
7.4.270.0030.00316.60
7.4.260.0050.00013.20
7.4.250.0040.00416.59
7.4.240.0020.00516.55
7.4.230.0070.00016.66
7.4.220.0030.00316.64
7.4.210.0070.01016.58
7.4.200.0000.00816.68
7.4.130.0130.00816.51
7.4.120.0150.00616.54
7.4.110.0070.01416.46
7.4.100.0130.00316.51
7.4.90.0120.00616.59
7.4.80.0120.00419.39
7.4.70.0110.00716.52
7.4.60.0090.01216.52
7.4.50.0140.00416.63
7.4.40.0130.00316.28
7.4.30.0060.01016.29
7.4.20.0080.00816.29
7.4.10.0080.00816.52
7.4.00.0080.00816.26
7.3.330.0090.00016.38
7.3.320.0000.00613.38
7.3.310.0040.00416.49
7.3.300.0000.00716.45
7.3.290.0050.01116.45
7.3.280.0070.01116.43
7.3.260.0130.01016.64
7.3.230.0100.01016.24
7.3.210.0040.01216.35
7.3.200.0130.01016.39
7.3.190.0180.00416.58
7.3.180.0130.00316.56
7.3.170.0140.00316.64
7.3.160.0070.01016.52
7.3.150.0130.00316.49
7.3.140.0060.01016.43
7.3.130.0120.00316.22
7.3.120.0130.00316.21
7.3.110.0060.01016.60
7.3.100.0060.01116.32
7.3.90.0100.00616.61
7.3.80.0030.01316.36
7.3.70.0120.00916.50
7.3.60.0070.01016.53
7.3.50.0140.00316.39
7.3.40.0100.00716.48
7.3.30.0030.01316.38
7.3.20.0110.00716.45
7.3.10.0060.01216.53
7.3.00.0120.01216.45
7.2.330.0110.01416.75
7.2.320.0090.00916.91
7.2.310.0090.00916.41
7.2.300.0060.01216.70
7.2.290.0060.01016.70
7.2.280.0130.00316.44
7.2.270.0000.01616.38
7.2.260.0070.01016.46
7.2.250.0120.00416.72
7.2.240.0090.01516.57
7.2.230.0070.01016.71
7.2.220.0060.01216.73
7.2.210.0070.01616.80
7.2.200.0100.00716.71
7.2.190.0040.01316.49
7.2.180.0080.01116.56
7.2.170.0100.00716.64
7.2.160.0090.00816.55
7.2.150.0130.00616.62
7.2.140.0160.01116.73
7.2.130.0060.01616.61
7.2.120.0080.00816.68
7.2.110.0100.00716.68
7.2.100.0000.01616.44
7.2.90.0080.00816.57
7.2.80.0090.00916.36
7.2.70.0040.01216.52
7.2.60.0100.00716.62
7.2.50.0130.00316.61
7.2.40.0060.01216.75
7.2.30.0100.00716.77
7.2.20.0080.00816.71
7.2.10.0000.01616.69
7.2.00.0120.00416.47

preferences:
73.03 ms | 403 KiB | 5 Q