3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = [ [ "id" => 96, "shipping_no" => "212755-1", "part_no" => "reterty", "description" => "tyrfyt", "packaging_type" => "PC" ], [ "id" => 96, "shipping_no" => "212755-1", "part_no" => "dftgtryh", "description" => "dfhgfyh", "packaging_type" => "PC" ], [ "id" => 97, "shipping_no" => "212755-2", "part_no" => "ZeoDark", "description" => "s%c%s%c%s", "packaging_type" => "PC" ] ]; function array_group_by($arr, array $keys) { if (!is_array($arr)) { trigger_error('array_group_by(): The first argument should be an array', E_USER_ERROR); } if (count($keys) == 0) { trigger_error('array_group_by(): The Second argument Array can not be empty', E_USER_ERROR); } // Load the new array, splitting by the target key $grouped = []; foreach ($arr as $value) { $grouped[$value[$keys[0]]][] = $value; } // Recursively build a nested grouping if more parameters are supplied // Each grouped array value is grouped according to the next sequential key if (count($keys) > 1) { foreach ($grouped as $key => $value) { $parms = array_merge([$value], [array_slice($keys, 1, count($keys))]); $grouped[$key] = call_user_func_array('array_group_by', $parms); } } return $grouped; } var_export( array_group_by($array, ['id', 'shipping_no']) );

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.03
8.4.150.0020.00014.05
8.4.140.0150.00817.61
8.4.130.0120.00918.76
8.4.120.0090.00918.88
8.4.110.0140.00718.98
8.4.100.0060.00317.97
8.4.90.0090.00820.40
8.4.80.0040.00618.98
8.4.70.0160.00519.14
8.4.60.0150.00520.41
8.4.50.0130.00718.64
8.4.40.0150.00418.52
8.4.30.0090.00624.01
8.4.20.0120.00919.61
8.4.10.0080.00819.59
8.3.280.0090.01018.51
8.3.270.0150.00716.84
8.3.260.0090.01216.48
8.3.250.0110.00816.59
8.3.240.0100.00916.57
8.3.230.0110.00616.71
8.3.220.0120.00718.85
8.3.210.0080.00716.73
8.3.200.0040.00516.48
8.3.190.0080.00317.05
8.3.180.0120.00720.75
8.3.170.0070.01119.25
8.3.160.0110.00720.68
8.3.150.0100.01018.82
8.3.140.0080.00818.39
8.3.130.0040.00416.52
8.3.120.0360.00716.57
8.3.110.0300.01316.41
8.3.100.0400.00816.65
8.3.90.0350.01016.73
8.3.80.0410.00616.39
8.3.70.0420.00416.55
8.3.60.0360.01116.82
8.3.50.0380.01016.59
8.3.40.0420.00017.41
8.3.30.0290.00917.35
8.3.20.0330.00317.58
8.3.10.0320.00617.55
8.3.00.0150.01219.24
8.2.290.0100.00917.51
8.2.280.0090.01018.56
8.2.270.0110.00716.66
8.2.260.0090.00617.18
8.2.250.0040.00416.50
8.2.240.0200.00316.49
8.2.230.0210.01216.43
8.2.220.0220.00016.22
8.2.210.0210.00016.61
8.2.200.0280.00316.45
8.2.190.0270.01016.38
8.2.180.0100.01016.41
8.2.170.0360.00317.59
8.2.160.0300.01217.69
8.2.150.0180.01117.44
8.2.140.0360.00717.44
8.2.130.0490.00317.51
8.2.120.0390.01017.42
8.2.110.0290.00817.66
8.2.100.0170.00317.68
8.2.90.0240.00317.46
8.2.80.0280.00717.63
8.2.70.0330.00717.57
8.2.60.0260.01117.58
8.2.50.0300.01017.52
8.2.40.0270.01117.63
8.2.30.0270.01117.51
8.2.20.0410.00317.63
8.2.10.0260.01017.53
8.2.00.0190.00617.59
8.1.330.0120.00716.37
8.1.320.0110.01116.20
8.1.310.0110.00716.97
8.1.300.0220.01515.82
8.1.290.0460.00016.23
8.1.280.0360.00416.18
8.1.270.0380.00617.15
8.1.260.0370.00617.32
8.1.250.0360.01217.19
8.1.240.0230.00817.38
8.1.230.0090.00917.28
8.1.220.0330.00317.11
8.1.210.0370.00317.26
8.1.200.0310.01217.42
8.1.190.0290.01217.05
8.1.180.0290.01217.05
8.1.170.0210.01217.28
8.1.160.0370.00017.10
8.1.150.0430.00817.12
8.1.140.0330.00617.11
8.1.130.0170.02117.11
8.1.120.0280.01417.47
8.1.110.0310.01217.04
8.1.100.0210.00916.86
8.1.90.0230.00817.17
8.1.80.0220.00917.04
8.1.70.0200.01017.03
8.1.60.0300.00317.24
8.1.50.0270.00517.26
8.1.40.0270.00617.22
8.1.30.0380.00317.47
8.1.20.0400.00017.22
8.1.10.0380.01017.32
8.1.00.0460.00717.19

preferences:
34.37 ms | 403 KiB | 5 Q