3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr = array( /*array('product_code' => 'battle-for-zendikar-token-1', 'product' => 'battle-for-zendikar-token-1'), array('product_code' => 'battle-for-zendikar-token-2', 'product' => 'battle-for-zendikar-token-2'), array('product_code' => 'battle-for-zendikar-token-3', 'product' => 'battle-for-zendikar-token-3'), array('product_code' => 'battle-for-zendikar-token-4', 'product' => 'battle-for-zendikar-token-4'), array('product_code' => 'battle-for-zendikar-token-5', 'product' => 'battle-for-zendikar-token-5'), array('product_code' => 'battle-for-zendikar-token-6', 'product' => 'battle-for-zendikar-token-6'), array('product_code' => 'battle-for-zendikar-token-7', 'product' => 'battle-for-zendikar-token-7'), array('product_code' => 'battle-for-zendikar-token-8', 'product' => 'battle-for-zendikar-token-8'), array('product_code' => 'battle-for-zendikar-token-9', 'product' => 'battle-for-zendikar-token-9'), array('product_code' => 'battle-for-zendikar-token-10', 'product' => 'battle-for-zendikar-token-10'), array('product_code' => 'battle-for-zendikar-token-11', 'product' => 'battle-for-zendikar-token-11'), array('product_code' => 'battle-for-zendikar-token-12', 'product' => 'battle-for-zendikar-token-12'), array('product_code' => 'battle-for-zendikar-token-13', 'product' => 'battle-for-zendikar-token-13'), array('product_code' => 'battle-for-zendikar-token-14', 'product' => 'battle-for-zendikar-token-14'),*/ array('product_code' => 'battle-for-zendikar-1', 'product' => 'battle-for-zendikar-1'), array('product_code' => 'battle-for-zendikar-2', 'product' => 'battle-for-zendikar-2'), array('product_code' => 'battle-for-zendikar-3', 'product' => 'battle-for-zendikar-3'), array('product_code' => 'battle-for-zendikar-4', 'product' => 'battle-for-zendikar-4'), array('product_code' => 'battle-for-zendikar-5', 'product' => 'battle-for-zendikar-5'), array('product_code' => 'battle-for-zendikar-6', 'product' => 'battle-for-zendikar-6'), array('product_code' => 'battle-for-zendikar-7', 'product' => 'battle-for-zendikar-7'), array('product_code' => 'battle-for-zendikar-8', 'product' => 'battle-for-zendikar-8'), array('product_code' => 'battle-for-zendikar-9', 'product' => 'battle-for-zendikar-9'), array('product_code' => 'battle-for-zendikar-10', 'product' => 'battle-for-zendikar-10'), array('product_code' => 'battle-for-zendikar-11', 'product' => 'battle-for-zendikar-11'), array('product_code' => 'battle-for-zendikar-12', 'product' => 'battle-for-zendikar-12'), array('product_code' => 'battle-for-zendikar-13', 'product' => 'battle-for-zendikar-13'), array('product_code' => 'battle-for-zendikar-14', 'product' => 'battle-for-zendikar-14'), array('product_code' => 'battle-for-zendikar-15', 'product' => 'battle-for-zendikar-15'), array('product_code' => 'battle-for-zendikar-16', 'product' => 'battle-for-zendikar-16'), array('product_code' => 'battle-for-zendikar-17', 'product' => 'battle-for-zendikar-17'), array('product_code' => 'battle-for-zendikar-18', 'product' => 'battle-for-zendikar-18'), array('product_code' => 'battle-for-zendikar-19', 'product' => 'battle-for-zendikar-19'), array('product_code' => 'battle-for-zendikar-20', 'product' => 'battle-for-zendikar-20') ); function sortProducts($products) { $_sorted = array(); $_unsortable = array(); $_numbers = array(); if (is_array($products) && count($products)) { foreach ($products as $product) { preg_match('/[0-9]+$/', $product['product_code'], $_numbers); $_number = $_numbers[0]; $initial_code_part = substr($product['product_code'],0,strrpos($product['product_code'],$_number)); if (!empty($_number)) { $_sorted[$initial_code_part][$_number] = $product; continue; } $_unsortable[$product['product_code']] = $product; } if (count($_sorted) > 1) { $_newSortedData = array(); $_sorted = array_reverse($_sorted); foreach ($_sorted as $_sortKey => $_sortedData) { if (!count($_newSortedData)) { $_newSortedData = $_sortedData; } else { foreach ($_sortedData as $item) { array_push($_newSortedData,$item); } //$params = $_sortedData; //array_unshift($params,$_newSortedData); //call_user_func_array('array_unshift'), //var_dump($params); //call_user_func_array('array_push',$params); } } $_sorted = $_newSortedData; } else { $_sorted = $_sorted[key($_sorted)]; } ksort($_sorted); ksort($_unsortable); if (!count($_sorted)) { return $_unsortable; } return $_sorted + $_unsortable; } return $products; } var_dump(sortProducts($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.0100.01018.20
8.3.50.0130.01021.18
8.3.40.0120.00319.08
8.3.30.0040.01118.95
8.3.20.0030.00520.33
8.3.10.0080.00023.51
8.3.00.0030.00619.67
8.2.180.0080.01118.67
8.2.170.0040.01222.96
8.2.160.0040.01220.52
8.2.150.0080.00024.18
8.2.140.0080.00824.66
8.2.130.0040.01126.16
8.2.120.0060.00317.88
8.2.110.0100.00021.04
8.2.100.0060.00618.09
8.2.90.0050.00318.34
8.2.80.0000.00918.10
8.2.70.0040.00417.93
8.2.60.0000.00918.02
8.2.50.0100.00018.10
8.2.40.0040.00420.45
8.2.30.0000.00819.93
8.2.20.0030.00617.93
8.2.10.0000.00818.07
8.2.00.0040.00418.22
8.1.280.0200.00325.92
8.1.270.0030.00520.23
8.1.260.0080.00026.35
8.1.250.0040.00428.09
8.1.240.0030.00622.61
8.1.230.0080.00420.91
8.1.220.0040.00417.75
8.1.210.0030.00518.77
8.1.200.0030.00517.48
8.1.190.0030.00717.47
8.1.180.0000.00818.10
8.1.170.0000.00818.66
8.1.160.0040.00422.13
8.1.150.0040.00418.92
8.1.140.0040.00417.66
8.1.130.0050.00217.72
8.1.120.0030.00517.62
8.1.110.0000.00817.60
8.1.100.0030.00517.66
8.1.90.0000.00817.62
8.1.80.0030.00517.46
8.1.70.0000.00717.58
8.1.60.0030.00617.73
8.1.50.0030.00617.57
8.1.40.0080.00417.57
8.1.30.0000.00817.66
8.1.20.0050.00317.85
8.1.10.0000.00917.70
8.1.00.0000.00817.71
8.0.300.0070.00019.79
8.0.290.0000.00816.88
8.0.280.0040.00418.48
8.0.270.0070.00017.29
8.0.260.0040.00417.25
8.0.250.0050.00317.18
8.0.240.0070.00017.20
8.0.230.0050.00217.21
8.0.220.0030.00317.08
8.0.210.0040.00417.07
8.0.200.0070.00017.21
8.0.190.0090.00017.14
8.0.180.0050.00317.21
8.0.170.0040.00417.19
8.0.160.0000.00717.07
8.0.150.0000.00717.04
8.0.140.0040.00417.00
8.0.130.0000.00613.58
8.0.120.0030.00617.06
8.0.110.0030.00517.14
8.0.100.0060.00316.96
8.0.90.0040.00416.96
8.0.80.0080.00816.99
8.0.70.0040.00417.06
8.0.60.0050.00317.11
8.0.50.0030.00517.00
8.0.30.0150.00517.22
8.0.20.0140.00917.40
8.0.10.0030.00517.18
8.0.00.0100.01016.99
7.4.330.0030.00315.20
7.4.320.0070.00016.87
7.4.300.0030.00316.86
7.4.290.0040.00416.62
7.4.280.0060.00316.63
7.4.270.0030.00316.62
7.4.260.0000.00716.80
7.4.250.0040.00416.83
7.4.240.0020.00616.75
7.4.230.0000.00716.89
7.4.220.0090.00916.67
7.4.210.0060.00916.71
7.4.200.0040.00416.86
7.4.160.0120.00416.79
7.4.150.0040.01717.40
7.4.140.0110.01317.86
7.4.130.0100.01116.69
7.4.120.0110.00816.72
7.4.110.0060.02116.71
7.4.100.0030.02016.64
7.4.90.0130.00616.70
7.4.80.0160.00819.39
7.4.70.0040.01416.72
7.4.60.0090.00916.59
7.4.50.0060.00316.78
7.4.40.0140.00616.63
7.4.30.0030.01716.90
7.4.00.0090.00315.41
7.3.330.0000.00613.50
7.3.320.0030.00313.64
7.3.310.0030.00616.58
7.3.300.0030.00316.45
7.3.290.0070.01016.49
7.3.280.0050.01116.56
7.3.270.0100.01017.40
7.3.260.0100.01016.84
7.3.250.0070.01316.67
7.3.240.0110.01116.96
7.3.230.0070.01816.41
7.3.210.0060.01316.87
7.3.200.0140.00516.73
7.3.190.0090.00916.48
7.3.180.0110.00616.63
7.3.170.0130.00316.82
7.3.160.0080.01616.71
7.2.330.0080.01216.97
7.2.320.0070.01017.01
7.2.310.0160.00016.87
7.2.300.0160.01016.93
7.2.290.0060.01916.89
7.2.60.0090.00317.13
7.2.00.0040.01219.56
7.1.200.0030.00916.07
7.1.100.0030.00918.18
7.1.70.0060.00617.17
7.1.60.0070.00419.12
7.1.50.0000.01116.87
7.1.00.0030.07322.32
7.0.200.0000.01116.61
7.0.60.0070.07721.71
7.0.50.0130.07717.91
7.0.40.0070.06320.13
7.0.30.0370.07020.35
7.0.20.0300.06320.27
7.0.10.0000.06320.11
7.0.00.0070.05020.09
5.6.280.0030.05721.04
5.6.210.0130.05320.77
5.6.200.0030.04018.16
5.6.190.0070.07320.39
5.6.180.0300.08020.33
5.6.170.0200.08020.73
5.6.160.0130.08020.55
5.6.150.0100.05718.22
5.6.140.0100.08318.13
5.6.130.0070.09018.18
5.6.120.0030.08721.01
5.6.110.0130.08021.15
5.6.100.0100.06721.04
5.6.90.0130.05721.14
5.6.80.0030.04720.41
5.5.350.4170.03720.36
5.5.340.0100.08018.05
5.5.330.0000.04320.27
5.5.320.0200.05020.36
5.5.310.0270.06720.31
5.5.300.0100.08317.94
5.5.290.0000.05018.08
5.5.280.0030.08720.87
5.5.270.0070.08321.00
5.5.260.0170.07320.75
5.5.250.0230.06320.56
5.5.240.0130.07020.29
5.4.450.4230.03019.26
5.4.440.0030.04019.35
5.4.430.1270.04319.54
5.4.420.3270.03719.33
5.4.410.4030.04319.26
5.4.400.3930.03019.07
5.4.390.3900.03719.07
5.4.380.4130.03019.01
5.4.370.4330.03718.93
5.4.360.4830.04319.11
5.4.350.4530.04318.98
5.4.340.4330.03018.93
5.4.320.4100.03719.15
5.4.310.4570.03319.18
5.4.300.4270.03719.00
5.4.290.4270.03719.11
5.4.280.4300.03719.17
5.4.270.4400.03718.96
5.4.260.4570.04018.95
5.4.250.4470.03719.20
5.4.240.4530.04019.16
5.4.230.3930.04318.90
5.4.220.4430.03718.89
5.4.210.4570.03318.91
5.4.200.4470.03719.11
5.4.190.3970.03319.16
5.4.180.3900.03719.14
5.4.170.3870.04019.11
5.4.160.4300.04019.18
5.4.150.4900.04719.00
5.4.140.4730.03016.46
5.4.130.4630.03716.55
5.4.120.3730.03716.49
5.4.110.4130.03016.55
5.4.100.4600.03016.51
5.4.90.4530.03716.33
5.4.80.4100.03016.45

preferences:
39.67 ms | 401 KiB | 5 Q