3v4l.org

run code in 300+ PHP versions simultaneously
<?php function array_group_by($arr, $key) { if (!is_array($arr)) { trigger_error('array_group_by(): The first argument should be an array', E_USER_ERROR); } if (!is_string($key) && !is_int($key) && !is_float($key)) { trigger_error('array_group_by(): The key should be a string or an integer', E_USER_ERROR); } // Load the new array, splitting by the target key $grouped = array(); foreach ($arr as $value) { $grouped[$value[$key]][] = $value; } // Recursively build a nested grouping if more parameters are supplied // Each grouped array value is grouped according to the next sequential key if (func_num_args() > 2) { $args = func_get_args(); foreach ($grouped as $key => $value) { $parms = array_merge(array($value), array_slice($args, 2, func_num_args())); $grouped[$key] = call_user_func_array('array_group_by', $parms); } } return $grouped; } $rows = array( array( 'name' => 'This is apple', 'category' => 'apple', 'first_category' => 'fruit' ), array( 'name' => 'This is orange', 'category' => 'orange', 'first_category' => 'fruit' ), array( 'name' => 'This is pear', 'category' => 'pear', 'first_category' => 'fruit' ), array( 'name' => 'This is carrot', 'category' => 'carrot', 'first_category' => 'vegetable' ), array( 'name' => 'This is tomatoe', 'category' => 'tomatoe', 'first_category' => 'vegetable' ) ); $items = array_group_by($rows, 'first_category'); foreach($items as $key => $value) { echo '<li><strong>' . $key . '</strong></li>'; foreach($value as $row) { echo '<li><a href="/category/'.$row['category'].'">'.$row['category'].'</a></li>'; } }

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.140.0050.00417.57
8.4.130.0030.00619.03
8.4.120.0140.00717.84
8.4.110.0170.00419.26
8.4.100.0070.00917.80
8.4.90.0090.01020.74
8.4.80.0080.01118.71
8.4.70.0070.01217.81
8.4.60.0100.01118.85
8.4.50.0100.00720.49
8.4.40.0100.01019.20
8.4.30.0140.00717.66
8.4.20.0130.00317.79
8.4.10.0060.00317.54
8.3.270.0140.00916.66
8.3.260.0150.00416.70
8.3.250.0120.00916.68
8.3.240.0130.00716.75
8.3.230.0090.01016.66
8.3.220.0100.00919.24
8.3.210.0110.00718.45
8.3.200.0050.00316.54
8.3.190.0110.00917.50
8.3.180.0160.00217.33
8.3.170.0040.00420.92
8.3.160.0100.01017.30
8.3.150.0000.01816.75
8.3.140.0070.00516.92
8.3.130.0080.00416.55
8.3.120.0060.00319.16
8.3.110.0120.00420.94
8.3.100.0100.00024.06
8.3.90.0050.00326.77
8.3.80.0030.00716.66
8.3.70.0100.01016.58
8.3.60.0090.01216.63
8.3.50.0120.01022.06
8.3.40.0040.01118.89
8.3.30.0110.00418.78
8.3.20.0070.00020.16
8.3.10.0040.00420.41
8.3.00.0040.00421.02
8.2.290.0090.00916.71
8.2.280.0130.00618.50
8.2.270.0070.01117.30
8.2.260.0030.00616.92
8.2.250.0090.00918.37
8.2.240.0040.00418.85
8.2.230.0080.00022.58
8.2.220.0000.00937.54
8.2.210.0070.01126.77
8.2.200.0060.00318.41
8.2.190.0090.00616.58
8.2.180.0060.00925.92
8.2.170.0100.01018.91
8.2.160.0070.00722.96
8.2.150.0040.00424.18
8.2.140.0080.00024.66
8.2.130.0140.00426.16
8.2.120.0000.00819.77
8.2.110.0070.00320.99
8.2.100.0040.00817.97
8.2.90.0000.00817.91
8.2.80.0050.00519.34
8.2.70.0030.00518.02
8.2.60.0050.00318.05
8.2.50.0090.00018.10
8.2.40.0070.00020.55
8.2.30.0040.00419.59
8.2.20.0040.00417.70
8.2.10.0040.00418.07
8.2.00.0040.00418.03
8.1.330.0140.00615.94
8.1.320.0110.00816.09
8.1.310.0170.00018.46
8.1.300.0060.01019.51
8.1.290.0030.00630.84
8.1.280.0150.00625.92
8.1.270.0050.00323.71
8.1.260.0040.00426.35
8.1.250.0080.00028.09
8.1.240.0000.00922.02
8.1.230.0030.00720.89
8.1.220.0030.00617.74
8.1.210.0030.00918.77
8.1.200.0000.01017.35
8.1.190.0060.00317.23
8.1.180.0060.00318.10
8.1.170.0060.00318.48
8.1.160.0040.00422.15
8.1.150.0040.00418.90
8.1.140.0040.00419.64
8.1.130.0070.00017.75
8.1.120.0000.00717.54
8.1.110.0000.00817.50
8.1.100.0040.00417.41
8.1.90.0000.00817.38
8.1.80.0030.00617.39
8.1.70.0000.00717.37
8.1.60.0040.00417.58
8.1.50.0000.00817.39
8.1.40.0030.00517.49
8.1.30.0040.00517.56
8.1.20.0030.00517.64
8.1.10.0080.00017.46
8.1.00.0000.00717.41
8.0.300.0000.00720.04
8.0.290.0040.00416.63
8.0.280.0050.00318.36
8.0.270.0000.00717.28
8.0.260.0090.00017.18
8.0.250.0070.00016.87
8.0.240.0040.00416.85
8.0.230.0070.00016.86
8.0.220.0000.00716.88
8.0.210.0070.00016.89
8.0.200.0050.00216.94
8.0.190.0040.00416.86
8.0.180.0000.00716.84
8.0.170.0000.00816.88
8.0.160.0050.00216.98
8.0.150.0070.00016.83
8.0.140.0030.00516.71
8.0.130.0000.00613.31
8.0.120.0040.00416.83
8.0.110.0000.00716.72
8.0.100.0040.00416.88
8.0.90.0000.00716.95
8.0.80.0040.01416.78
8.0.70.0040.00416.94
8.0.60.0030.00316.92
8.0.50.0070.00016.89
8.0.30.0080.00917.17
8.0.20.0080.01117.40
8.0.10.0040.00416.91
8.0.00.0060.01216.63
7.4.330.0020.00215.08
7.4.320.0030.00316.51
7.4.300.0000.00616.43
7.4.290.0030.00316.42
7.4.280.0030.00616.52
7.4.270.0000.00716.48
7.4.260.0030.00316.52
7.4.250.0060.00316.52
7.4.240.0070.00016.56
7.4.230.0040.00416.68
7.4.220.0110.01416.52
7.4.210.0060.00916.53
7.4.200.0030.00316.63
7.4.160.0090.00616.58
7.4.150.0090.00917.40
7.4.140.0060.01317.86
7.4.130.0120.00916.42
7.4.120.0080.01016.48
7.4.110.0090.00916.48
7.4.100.0100.01416.34
7.4.90.0110.00616.50
7.4.80.0130.00619.39
7.4.70.0160.00716.53
7.4.60.0070.01016.52
7.4.50.0060.00916.28
7.4.40.0150.01116.58
7.4.30.0090.01116.51
7.4.00.0100.00714.79
7.3.330.0050.00013.15
7.3.320.0020.00213.37
7.3.310.0070.00016.39
7.3.300.0000.00816.32
7.3.290.0100.00516.38
7.3.280.0070.01116.34
7.3.270.0030.01817.40
7.3.260.0170.00916.45
7.3.250.0090.01116.33
7.3.240.0100.01116.48
7.3.230.0120.00616.39
7.3.210.0100.01316.49
7.3.200.0060.00919.39
7.3.190.0100.00616.38
7.3.180.0110.00416.36
7.3.170.0060.01616.61
7.3.160.0130.00316.61
7.2.330.0100.00716.42
7.2.320.0090.01216.82
7.2.310.0130.00316.88
7.2.300.0090.00916.54
7.2.290.0080.00816.91
7.2.80.0100.01316.66
7.2.60.0070.00717.03
7.2.00.0000.01219.55
7.1.200.0080.00416.00
7.1.100.0060.00617.90
7.1.70.0070.00717.09
7.1.60.0170.00719.19
7.1.00.0030.07722.54
7.0.200.0110.00416.80
7.0.100.0200.03720.07
7.0.90.0070.08719.88
7.0.80.0130.07719.93
7.0.70.0200.08019.98
7.0.60.0070.05019.94
7.0.50.0300.07320.24
7.0.40.0100.06720.14
7.0.30.0100.07720.03
7.0.20.0070.05720.05
7.0.10.0070.07720.04
7.0.00.0100.06020.17
5.6.280.0000.07320.91
5.6.250.0100.06720.70
5.6.240.0200.03720.65
5.6.230.0170.07720.64
5.6.220.0170.07320.49
5.6.210.0100.08320.75
5.6.200.0000.08321.05
5.6.190.0100.04321.12
5.6.180.0030.06720.96
5.6.170.0030.06720.96
5.6.160.0070.07721.12
5.6.150.0130.04721.03
5.6.140.0100.04720.94
5.6.130.0070.05721.09
5.6.120.0170.03021.17
5.6.110.0070.06721.04
5.6.100.0070.06321.09
5.6.90.0070.08021.03
5.6.80.0170.06020.50
5.6.70.0070.08720.40
5.6.60.0000.08020.44
5.6.50.0270.06320.50
5.6.40.0070.04720.50
5.6.30.0100.04720.46
5.6.20.0070.08320.40
5.6.10.0000.06020.40
5.6.00.0030.06720.48
5.5.380.0130.07720.44
5.5.370.0030.05020.36
5.5.360.0030.06020.36
5.5.350.0130.07320.43
5.5.340.0130.06320.75
5.5.330.0030.05020.77
5.5.320.0070.07020.93
5.5.310.0130.08020.65
5.5.300.0170.06320.75
5.5.290.0130.08020.89
5.5.280.0070.08720.92
5.5.270.0000.06020.86
5.5.260.0100.07720.93
5.5.250.0200.07020.70
5.5.240.0100.08020.33
5.5.230.0100.07020.32
5.5.220.0070.08320.21
5.5.210.0100.07720.04
5.5.200.0130.06320.20
5.5.190.0100.04720.09
5.5.180.0170.07020.16
5.5.160.0100.04020.19
5.5.150.0130.04020.09
5.5.140.0270.05720.23
5.5.130.0070.08320.28
5.5.120.0200.06720.16
5.5.110.0170.05320.18
5.5.100.0030.04319.96
5.5.90.0000.04319.94
5.5.80.0100.07320.08
5.5.70.0070.06720.07
5.5.60.0170.06719.99
5.5.50.0030.07720.04
5.5.40.0130.07019.95
5.5.30.0070.04319.90
5.5.20.0170.06320.08
5.5.10.0170.07020.00
5.5.00.0070.07319.96
5.4.450.0000.07019.22
5.4.440.0000.06019.46
5.4.430.0030.05019.53
5.4.420.0200.07019.16
5.4.410.0030.04719.45
5.4.400.0000.05318.88
5.4.390.0130.06318.89
5.4.380.0130.05318.92
5.4.370.0000.08319.16
5.4.360.0030.07018.90
5.4.350.0070.07019.04
5.4.340.0100.07719.16
5.4.320.0070.04319.03
5.4.310.0030.07719.03
5.4.300.0170.06318.84
5.4.290.0170.07018.90
5.4.280.0100.07019.22
5.4.270.0170.06318.94
5.4.260.0200.06318.84
5.4.250.0070.05719.20
5.4.240.0070.04019.12
5.4.230.0100.07019.23
5.4.220.0030.07319.02
5.4.210.0030.07719.04
5.4.200.0000.09018.89
5.4.190.0100.06718.86
5.4.180.0100.07019.04
5.4.170.0070.07719.15
5.4.160.0130.07318.89
5.4.150.0100.07718.83
5.4.140.0070.07316.38
5.4.130.0100.05316.30
5.4.120.0100.05716.41
5.4.110.0130.05716.36
5.4.100.0100.07316.53
5.4.90.0030.06716.53
5.4.80.0100.06716.43
5.4.70.0070.06016.49
5.4.60.0030.07716.31
5.4.50.0100.05316.40
5.4.40.0100.05716.51
5.4.30.0200.05716.44
5.4.20.0130.03716.39
5.4.10.0070.07316.30
5.4.00.0070.07315.81
5.3.290.0130.07314.77
5.3.280.0070.06714.55
5.3.270.0030.05014.54
5.3.260.0170.07014.57
5.3.250.0170.05714.68
5.3.240.0030.07014.54
5.3.230.0100.05714.59
5.3.220.0100.05714.68
5.3.210.0130.07314.53
5.3.200.0070.07714.50
5.3.190.0070.07014.68
5.3.180.0130.07014.70
5.3.170.0100.07014.59
5.3.160.0100.05714.64
5.3.150.0030.04714.54
5.3.140.0100.06714.62
5.3.130.0030.05314.62
5.3.120.0100.07014.52
5.3.110.0030.04714.67
5.3.100.0100.07314.00
5.3.90.0070.06013.96
5.3.80.0070.07313.96
5.3.70.0000.05713.94
5.3.60.0030.06013.90
5.3.50.0170.04713.95
5.3.40.0100.03714.01
5.3.30.0070.06713.95
5.3.20.0000.06313.84
5.3.10.0000.06713.76
5.3.00.0070.04313.54
5.2.170.0130.05311.96
5.2.160.0030.06711.96
5.2.150.0100.05311.96
5.2.140.0030.06011.96
5.2.130.0030.05011.96
5.2.120.0030.04711.96
5.2.110.0070.04011.96
5.2.100.0030.04311.96
5.2.90.0070.04711.96
5.2.80.0100.04011.96
5.2.70.0070.03011.96
5.2.60.0030.05711.96
5.2.50.0070.03711.96
5.2.40.0030.05711.96
5.2.30.0070.05711.96
5.2.20.0030.06011.96
5.2.10.0030.06011.96
5.2.00.0100.05311.96
5.1.60.0030.05311.96
5.1.50.0100.05011.96
5.1.40.0000.05711.96
5.1.30.0070.04011.96
5.1.20.0030.05711.96
5.1.10.0030.02311.96
5.1.00.0070.05311.96
5.0.50.0000.04311.96
5.0.40.0000.02311.96
5.0.30.0070.05311.96
5.0.20.0000.04011.96
5.0.10.0100.03711.96
5.0.00.0130.04711.96
4.4.90.0030.02011.96
4.4.80.0030.02711.96
4.4.70.0030.01711.96
4.4.60.0000.03711.96
4.4.50.0030.03711.96
4.4.40.0000.03311.96
4.4.30.0030.02311.96
4.4.20.0000.03711.96
4.4.10.0030.01711.96
4.4.00.0030.05011.96
4.3.110.0000.02311.96
4.3.100.0070.03011.96
4.3.90.0030.03311.96
4.3.80.0000.05011.96
4.3.70.0000.01711.96
4.3.60.0070.03311.96
4.3.50.0070.02011.96
4.3.40.0030.03311.96
4.3.30.0070.02711.96
4.3.20.0070.01311.96
4.3.10.0000.03711.96
4.3.00.0000.03011.96

preferences:
120.53 ms | 403 KiB | 5 Q