3v4l.org

run code in 300+ PHP versions simultaneously
<?php $order = array( 3452342, 5867867, 7867867, 1231233 ); $array = array( array("id" => 7867867, "title" => "Must Be #3"), array("id" => 3452342, "title" => "Must Be #1"), array("id" => 1231233, "title" => "Must Be #4"), array("id" => 5867867, "title" => "Must Be #2"), array("id" => 1111111, "title" => "Dont Care #1"), array("id" => 2222222, "title" => "Dont Care #2"), array("id" => 3333333, "title" => "Dont Care #3"), array("id" => 4444444, "title" => "Dont Care #4") ); function custom_compare($a, $b){ global $order; $a = array_search($a["id"], $order); $b = array_search($b["id"], $order); if($a === false && $b === false) { // both items are dont cares return 0; // a == b } else if ($a === false) { // $a is a dont care item return 1; // $a > $b } else if ($b === false) { // $b is a dont care item return -1; // $a < $b } else { return $a - $b; } } shuffle($array); // for testing var_dump($array); // before usort($array, "custom_compare"); var_dump($array); // after ?>

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)
7.2.00.0060.00619.07
7.1.70.0000.01117.34
7.1.60.0090.01519.70
7.1.50.0030.00916.65
7.1.00.0100.07022.43
7.0.200.0490.01214.60
7.0.140.0100.06722.09
7.0.60.0130.03719.95
7.0.50.0070.07317.84
7.0.40.0170.07720.16
7.0.30.0270.05320.25
7.0.20.0300.04320.06
7.0.10.0070.05020.12
7.0.00.0230.04320.09
5.6.280.0130.06721.00
5.6.210.0100.07020.73
5.6.200.0130.07718.13
5.6.190.0030.07320.52
5.6.180.0230.05020.47
5.6.170.0330.07320.52
5.6.160.0170.07720.47
5.6.150.0030.08018.14
5.6.140.0000.09018.18
5.6.130.0030.04318.14
5.6.120.0030.05721.15
5.6.110.0070.03721.02
5.6.100.0100.03321.03
5.6.90.0100.08320.98
5.6.80.0100.08020.36
5.5.350.3200.03320.34
5.5.340.0100.04018.07
5.5.330.0070.04720.26
5.5.320.0370.07320.34
5.5.310.0330.06720.41
5.5.300.0130.05317.99
5.5.290.0130.04018.08
5.5.280.0070.05320.85
5.5.270.0170.06720.87
5.5.260.0130.07720.80
5.5.250.0100.07720.71
5.5.240.0030.07320.19
5.4.450.4200.04019.54
5.4.440.0070.04019.45
5.4.430.1730.07019.43
5.4.420.4570.03719.55
5.4.410.4200.03719.13
5.4.400.4270.03718.95
5.4.390.2200.03318.96
5.4.380.3830.04319.03
5.4.370.3000.03319.11
5.4.360.3230.03719.21
5.4.350.4100.03719.22
5.4.340.5470.03318.99
5.4.320.3870.04319.14
5.4.310.3730.03719.25
5.4.300.3770.04319.20
5.4.290.3700.03719.03
5.4.280.4130.05018.95
5.4.270.3700.03319.20
5.4.260.3970.04719.11
5.4.250.4070.03319.03
5.4.240.4900.05018.96
5.4.230.4000.04719.25
5.4.220.4100.03719.20
5.4.210.3870.03319.21
5.4.200.4100.03719.20
5.4.190.4600.04019.16
5.4.180.4970.03319.17
5.4.170.4430.03719.21
5.4.160.4100.04719.04
5.4.150.3570.04018.92
5.4.140.3570.03316.26
5.4.130.3470.03716.53
5.4.120.4170.03016.51
5.4.110.4430.02316.32
5.4.100.3300.03716.50
5.4.90.0070.07316.53
5.4.80.2900.03716.53
5.4.70.4370.03016.51
5.4.60.4230.04316.49
5.4.50.3700.04016.49
5.4.40.4100.03716.43
5.4.30.3600.04016.30
5.4.20.4130.03316.49
5.4.10.4830.04316.48
5.4.00.4500.03715.80
5.3.290.3830.04314.82
5.3.280.3800.04014.75
5.3.270.4470.03714.52
5.3.260.4230.03714.52
5.3.250.3870.03314.61
5.3.240.3670.03714.64
5.3.230.4230.04014.67
5.3.220.4470.03314.57
5.3.210.4230.04014.73
5.3.200.4330.03014.57
5.3.190.0070.07314.62
5.3.180.0130.06314.48
5.3.170.4430.03714.64
5.3.160.4600.03314.63
5.3.150.4130.03714.62
5.3.140.4000.04714.55
5.3.130.4100.04014.58
5.3.120.3870.03314.54
5.3.110.4070.03714.59
5.3.100.4600.03314.20
5.3.90.0070.03714.08
5.3.80.0070.06014.01
5.3.70.0070.04714.17
5.3.60.2200.03714.09
5.3.50.4530.03314.00
5.3.40.5630.03713.95
5.3.30.4930.03714.07
5.3.20.4630.03713.84
5.3.10.4670.03013.80
5.3.00.4600.04713.64
5.2.170.3800.03311.16
5.2.160.3930.02711.14
5.2.150.3870.02311.18
5.2.140.3870.03311.16
5.2.130.3770.03011.16
5.2.120.3600.02711.14
5.2.110.3930.03011.10
5.2.100.3300.03011.15
5.2.90.2100.02711.14
5.2.80.1900.03011.09
5.2.70.2530.02011.00
5.2.60.2930.03311.20
5.2.50.2870.03011.08
5.2.40.2170.02711.05
5.2.30.2370.03010.94
5.2.20.2700.03710.92
5.2.10.2400.02710.91
5.2.00.2330.03010.88
5.1.60.2200.0209.97
5.1.50.2100.0279.91
5.1.40.2600.02710.12
5.1.30.2200.02310.50
5.1.20.2370.02310.41
5.1.10.2800.03010.05
5.1.00.2870.03010.08
5.0.50.1670.0208.55
5.0.40.1870.0208.48
5.0.30.1700.0378.39
5.0.20.1870.0238.11
5.0.10.1800.0208.17
5.0.00.1900.0278.18
4.4.90.1230.0137.92
4.4.80.1200.0137.92
4.4.70.1000.0107.92
4.4.60.1200.0137.92
4.4.50.1000.0137.92
4.4.40.1200.0237.92
4.4.30.1100.0177.92
4.4.20.1670.0207.92
4.4.10.1830.0207.92
4.4.00.1800.0277.92
4.3.110.1830.0137.92
4.3.100.1830.0137.92
4.3.90.1700.0207.92
4.3.80.1870.0237.92
4.3.70.1700.0137.92
4.3.60.1730.0177.92
4.3.50.1670.0137.92
4.3.40.1500.0277.92
4.3.30.1030.0177.92
4.3.20.0770.0177.92
4.3.10.0730.0177.92
4.3.00.0930.0207.92

preferences:
41.17 ms | 401 KiB | 5 Q