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(); foreach ($_sorted as $_sortKey => $_sortedData) { if (!count($_newSorteddata)) { $_newSortedData = $_sortedData; } else { $params = $_sortedData; array_shift($params,$_newSortedData); var_dump($params); call_user_func_array('array_push',$params); } } $_sorted = $_newSortedData; } 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.56
8.3.50.0160.00521.23
8.3.40.0090.00919.08
8.3.30.0040.01118.85
8.3.20.0000.00720.33
8.3.10.0080.00021.91
8.3.00.0060.00319.58
8.2.180.0080.00818.64
8.2.170.0140.00722.96
8.2.160.0060.01020.32
8.2.150.0060.00324.18
8.2.140.0040.00424.66
8.2.130.0080.00026.16
8.2.120.0090.00017.88
8.2.110.0100.00019.20
8.2.100.0060.00617.75
8.2.90.0000.00919.39
8.2.80.0030.00517.97
8.2.70.0080.00017.86
8.2.60.0060.00317.93
8.2.50.0050.00318.07
8.2.40.0050.00319.23
8.2.30.0090.00019.78
8.2.20.0040.00417.94
8.2.10.0040.00418.29
8.2.00.0060.00318.30
8.1.280.0030.01725.92
8.1.270.0120.00620.50
8.1.260.0080.00026.35
8.1.250.0040.00428.09
8.1.240.0000.01124.02
8.1.230.0080.00417.48
8.1.220.0040.00417.74
8.1.210.0060.00318.77
8.1.200.0090.00017.50
8.1.190.0040.00417.48
8.1.180.0000.00818.10
8.1.170.0090.00018.79
8.1.160.0000.00822.07
8.1.150.0040.00418.99
8.1.140.0060.00317.63
8.1.130.0040.00417.71
8.1.120.0000.00717.48
8.1.110.0040.00417.62
8.1.100.0070.00017.64
8.1.90.0000.00817.53
8.1.80.0000.00717.63
8.1.70.0030.00317.61
8.1.60.0080.00017.74
8.1.50.0000.00917.58
8.1.40.0060.00317.61
8.1.30.0060.00317.74
8.1.20.0030.00517.85
8.1.10.0000.00817.73
8.1.00.0000.00817.65
8.0.300.0040.00418.77
8.0.290.0000.00717.00
8.0.280.0040.00418.54
8.0.270.0070.00017.19
8.0.260.0030.00317.31
8.0.250.0040.00417.18
8.0.240.0030.00617.16
8.0.230.0040.00417.19
8.0.220.0020.00517.02
8.0.210.0050.00317.08
8.0.200.0030.00317.19
8.0.190.0100.00017.03
8.0.180.0050.00317.08
8.0.170.0040.00417.13
8.0.160.0060.00317.14
8.0.150.0030.00617.03
8.0.140.0000.00817.03
8.0.130.0060.00013.51
8.0.120.0000.00717.04
8.0.110.0000.00817.14
8.0.100.0050.00317.10
8.0.90.0040.00417.07
8.0.80.0060.01217.13
8.0.70.0030.00616.98
8.0.60.0050.00217.02
8.0.50.0000.00817.00
8.0.30.0100.01017.32
8.0.20.0160.00617.49
8.0.10.0040.00417.11
8.0.00.0090.00817.00
7.4.330.0070.00015.08
7.4.320.0000.00716.84
7.4.300.0000.00616.69
7.4.290.0030.00716.75
7.4.280.0030.00716.83
7.4.270.0050.00316.85
7.4.260.0050.00216.63
7.4.250.0070.00016.80
7.4.240.0020.00516.77
7.4.230.0000.00716.74
7.4.220.0090.00916.87
7.4.210.0090.01216.85
7.4.200.0050.00216.75
7.4.160.0190.00016.80
7.4.150.0090.01417.40
7.4.140.0070.01217.86
7.4.130.0110.00916.72
7.4.120.0110.01116.73
7.4.110.0060.01216.66
7.4.100.0150.01216.70
7.4.90.0160.00316.73
7.4.80.0120.00619.39
7.4.70.0210.00316.92
7.4.60.0070.01116.80
7.4.50.0040.00416.54
7.4.40.0130.00516.65
7.4.30.0110.01516.79
7.4.10.0090.00915.28
7.4.00.0050.01415.13
7.3.330.0050.00013.54
7.3.320.0030.00313.48
7.3.310.0050.00316.64
7.3.300.0000.00716.52
7.3.290.0030.00316.49
7.3.280.0080.00916.63
7.3.270.0170.00417.40
7.3.260.0160.00416.86
7.3.250.0110.00916.73
7.3.240.0150.01016.52
7.3.230.0060.01316.46
7.3.210.0100.01016.69
7.3.200.0030.02216.88
7.3.190.0150.00916.76
7.3.180.0170.00916.54
7.3.170.0120.00616.60
7.3.160.0110.01216.61
7.3.130.0090.00914.85
7.3.120.0110.00614.97
7.3.110.0090.00914.98
7.3.100.0080.00715.17
7.3.90.0110.00315.17
7.3.80.0030.01115.27
7.3.70.0050.01015.12
7.3.60.0060.00514.79
7.3.50.0050.00815.18
7.3.40.0020.01014.93
7.3.30.0070.00814.97
7.3.20.0080.00516.95
7.3.10.0100.00416.74
7.3.00.0070.00716.74
7.2.330.0110.01116.73
7.2.320.0120.00816.87
7.2.310.0070.01116.91
7.2.300.0130.00816.75
7.2.290.0200.00616.91
7.2.260.0070.01315.41
7.2.250.0030.01315.32
7.2.240.0030.01515.36
7.2.230.0090.00815.16
7.2.220.0090.00415.30
7.2.210.0050.00614.98
7.2.200.0100.00515.32
7.2.190.0080.00815.38
7.2.180.0080.00615.21
7.2.170.0050.00615.34
7.2.160.0060.01115.20
7.2.150.0070.00317.09
7.2.140.0060.01017.02
7.2.130.0100.00817.08
7.2.120.0070.01016.96
7.2.110.0090.00817.12
7.2.100.0090.00616.93
7.2.90.0140.00416.95
7.2.80.0070.00916.89
7.2.70.0070.00616.90
7.2.60.0100.00717.01
7.2.50.0120.00517.04
7.2.40.0030.01117.08
7.2.30.0130.00316.92
7.2.20.0130.00717.03
7.2.10.0110.00816.99
7.2.00.0070.00818.04
7.1.330.0070.00615.74
7.1.320.0100.00415.98
7.1.310.0100.00316.10
7.1.300.0060.00715.86
7.1.290.0070.00315.82
7.1.280.0050.00815.89
7.1.270.0050.00815.96
7.1.260.0080.00716.14
7.1.250.0020.01115.71
7.1.240.0070.00315.68
7.1.230.0050.00516.09
7.1.220.0130.00316.03
7.1.210.0110.00416.10
7.1.200.0050.00816.05
7.1.190.0070.00315.86
7.1.180.0120.00615.93
7.1.170.0130.00316.11
7.1.160.0070.00716.11
7.1.150.0060.00915.75
7.1.140.0040.01215.75
7.1.130.0000.01515.87
7.1.120.0070.00716.08
7.1.110.0000.01516.15
7.1.100.0020.00917.25
7.1.90.0040.01115.88
7.1.80.0000.01615.96
7.1.70.0020.00916.42
7.1.60.0100.00717.48
7.1.50.0090.01016.64
7.1.40.0000.01515.91
7.1.30.0030.01015.83
7.1.20.0100.00315.95
7.1.10.0100.00615.82
7.1.00.0100.04019.09
7.0.330.0000.01015.30
7.0.320.0070.00715.13
7.0.310.0100.00315.35
7.0.300.0030.01015.70
7.0.290.0060.01015.71
7.0.280.0030.00915.55
7.0.270.0070.00715.12
7.0.260.0030.00615.57
7.0.250.0040.01115.57
7.0.240.0030.01015.49
7.0.230.0030.00615.58
7.0.220.0030.01615.52
7.0.210.0120.00315.34
7.0.200.0070.00516.28
7.0.190.0070.01015.65
7.0.180.0070.00315.68
7.0.170.0070.00315.73
7.0.160.0070.00715.54
7.0.150.0030.01015.24
7.0.140.0030.00715.38
7.0.130.0000.01415.58
7.0.120.0150.00015.46
7.0.110.0060.00915.29
7.0.100.0100.00615.53
7.0.90.0000.01115.30
7.0.80.0070.01115.33
7.0.70.0000.01015.45
7.0.60.0100.02217.64
7.0.50.0080.03516.81
7.0.40.0060.02617.02
7.0.30.0170.04416.97
7.0.20.0230.02516.76
7.0.10.0050.02316.95
7.0.00.0070.03916.90
5.6.400.0030.01414.87
5.6.390.0030.01014.62
5.6.380.0000.01314.52
5.6.370.0120.00314.56
5.6.360.0100.00014.21
5.6.350.0030.01014.40
5.6.340.0090.00614.25
5.6.330.0000.01114.64
5.6.320.0000.01414.32
5.6.310.0130.00714.36
5.6.300.0000.01014.58
5.6.290.0050.00514.86
5.6.280.0040.00714.68
5.6.270.0100.00614.55
5.6.260.0000.01714.74
5.6.250.0030.00614.45
5.6.240.0060.00914.50
5.6.230.0040.01514.54
5.6.220.0030.00614.49
5.6.210.0090.03717.51
5.6.200.0070.04216.46
5.6.190.0030.03017.55
5.6.180.0200.03717.63
5.6.170.0170.04317.60
5.6.160.0050.03417.47
5.6.150.0030.04216.35
5.6.140.0080.02316.48
5.6.130.0120.02616.29
5.6.120.0030.03317.67
5.6.110.0050.04717.73
5.6.100.0080.02617.88
5.6.90.0120.04017.74
5.6.80.0080.04617.47
5.6.70.0060.00914.57
5.6.60.0030.01414.66
5.6.50.0060.00914.45
5.6.40.0070.01114.51
5.6.30.0040.01214.48
5.6.20.0030.01314.61
5.6.10.0070.00714.33
5.6.00.0000.01414.79
5.5.380.0110.00414.58
5.5.370.0080.00814.75
5.5.360.0040.01414.57
5.5.350.0180.04217.74
5.5.340.0100.02516.34
5.5.330.0100.04317.21
5.5.320.0130.03517.31
5.5.310.0100.03017.49
5.5.300.0110.03816.43
5.5.290.0050.04316.11
5.5.280.0070.04517.76
5.5.270.0050.05217.58
5.5.260.0130.03817.52
5.5.250.0090.04017.63
5.5.240.0210.03417.32
5.5.230.0050.00514.36
5.5.220.0120.00314.59
5.5.210.0100.00714.58
5.5.200.0040.01114.54
5.5.190.0080.00414.55
5.5.180.0070.00714.47
5.5.170.0030.01014.13
5.5.160.0040.00714.71
5.5.150.0060.00614.50
5.5.140.0090.00914.43
5.5.130.0070.01014.59
5.5.120.0100.00614.49
5.5.110.0060.00314.68
5.5.100.0100.00314.56
5.5.90.0110.00314.32
5.5.80.0100.00314.27
5.5.70.0070.00714.34
5.5.60.0040.00714.28
5.5.50.0080.00414.65
5.5.40.0060.00914.70
5.5.30.0130.00314.33
5.5.20.0040.01214.75
5.5.10.0030.00913.96
5.5.00.0000.01514.05
5.4.450.0120.03315.41
5.4.440.0120.03815.35
5.4.430.0080.03515.17
5.4.420.0240.02515.51
5.4.410.0120.03015.38
5.4.400.0140.02715.28
5.4.390.0070.03615.23
5.4.380.0150.02915.05
5.4.370.0150.02815.14
5.4.360.0170.02515.09
5.4.350.0100.03115.14
5.4.340.0150.03015.19
5.4.330.0080.00311.23
5.4.320.0160.03315.14
5.4.310.0160.03015.14
5.4.300.0210.02115.20
5.4.290.0190.02715.25
5.4.280.0090.03415.29
5.4.270.0100.03115.26
5.4.260.0100.03115.05
5.4.250.0100.03215.24
5.4.240.0130.02815.27
5.4.230.0160.02615.25
5.4.220.0120.03015.37
5.4.210.0130.02715.09
5.4.200.0100.03215.22
5.4.190.0120.04615.16
5.4.180.0140.03015.26
5.4.170.0100.03215.12
5.4.160.0100.03315.08
5.4.150.0100.03715.18
5.4.140.0100.02813.83
5.4.130.0080.03214.06
5.4.120.0130.03113.93
5.4.110.0120.02913.95
5.4.100.0100.03013.95
5.4.90.0130.03014.04
5.4.80.0100.03113.68
5.4.70.0120.03913.89
5.4.60.0200.03713.96
5.4.50.0030.03913.84
5.4.40.0050.02014.05
5.4.30.0060.01813.83
5.4.20.0090.02013.82
5.4.10.0000.01111.35
5.4.00.0000.00811.13

preferences:
52.2 ms | 401 KiB | 5 Q