3v4l.org

run code in 500+ PHP versions simultaneously
<?php $allOptions = array( array("clID"=> 171), array("clID"=> 191), array("clID"=> 131), array("clID"=> 101), array("clID"=> 201), array("clID"=> 181), array("clID"=> 99), // not in regOptions array("clID"=> 129), // not in regOptions array("clID"=> 139), ) ; $regOptions = array( array("order"=>1,"optID"=> 131), array("order"=>2,"optID"=> 191), array("order"=>3,"optID"=> 181), array("order"=>4,"optID"=> 139), array("order"=>5,"optID"=> 101), array("order"=>6,"optID"=> 201), array("order"=>7,"optID"=> 171) ); // add indexes to the original array for faster lookups $indexedOptions = []; foreach($allOptions as $val) { $indexedOptions[$val['clID']] = $val; } $newArray = []; foreach ($regOptions as $order) { $id = $order['optID']; if (isset($indexedOptions[$id])) { $newArray[] = $indexedOptions[$id]; unset($indexedOptions[$id]); } } // at this point, $newArray has all of the found values in order, // and $indexedOptions has any remaining items. // var_dump($newArray); // var_dump($indexedOptions); // put them together for the final array $final = array_merge($newArray, $indexedOptions); var_dump($final);

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.80.0090.00816.68
8.5.70.0120.00518.55
8.5.60.0120.00818.44
8.5.50.0100.00916.75
8.5.30.0100.00719.61
8.5.20.0060.00220.34
8.5.10.0050.00416.63
8.5.00.0100.01219.84
8.4.230.0120.00822.29
8.4.220.0060.00325.91
8.4.210.0100.00919.48
8.4.180.0190.01021.95
8.4.170.0130.00922.15
8.4.160.0110.01123.86
8.4.150.0070.00516.81
8.4.140.0160.00617.64
8.4.130.0120.00917.64
8.4.120.0110.00920.58
8.4.110.0120.00822.33
8.4.100.0140.00718.60
8.4.90.0130.00719.35
8.4.80.0130.00817.67
8.4.70.0160.00417.69
8.4.60.0070.00318.45
8.4.50.0150.00617.84
8.4.40.0030.00617.55
8.4.30.0060.00320.60
8.4.20.0090.00017.88
8.4.10.0030.00619.36
8.3.320.0070.00418.55
8.3.310.0050.00320.13
8.3.300.0090.01120.72
8.3.290.0150.00618.27
8.3.280.0140.00618.27
8.3.270.0090.01016.50
8.3.260.0100.00916.74
8.3.250.0070.01118.99
8.3.240.0070.00117.27
8.3.230.0090.01116.50
8.3.220.0110.00817.24
8.3.210.0110.00416.83
8.3.200.0040.00516.80
8.3.190.0120.00919.18
8.3.180.0110.00816.41
8.3.170.0070.01118.99
8.3.160.0100.01018.41
8.3.150.0000.01517.29
8.3.140.0100.01016.55
8.3.130.0030.00618.59
8.3.120.0110.00018.98
8.3.110.0100.01020.94
8.3.100.0000.00916.53
8.3.90.0040.01126.77
8.3.80.0060.00317.97
8.3.70.0180.00418.43
8.3.60.0130.01018.46
8.3.50.0130.00918.35
8.3.40.0140.00720.34
8.3.30.0130.00721.70
8.3.20.0140.00424.18
8.3.10.0150.00324.66
8.3.00.0040.01426.16
8.2.310.0140.00618.25
8.2.300.0090.01218.02
8.2.290.0060.00220.67
8.2.280.0050.01418.29
8.2.270.0120.00617.27
8.2.260.0090.00916.45
8.2.250.0070.00716.72
8.2.240.0090.00017.32
8.2.230.0060.00322.58
8.2.220.0040.00424.06
8.2.210.0150.00026.77
8.2.200.0080.00418.16
8.2.190.0150.00618.41
8.2.180.0040.01116.50
8.2.170.0120.00318.96
8.2.160.0150.00022.96
8.2.150.0030.00525.66
8.2.140.0090.00024.66
8.2.130.0030.01326.16
8.2.120.0050.00319.66
8.2.110.0070.00420.52
8.2.100.0100.00020.69
8.2.90.0150.00320.45
8.2.80.0030.00718.89
8.2.70.0100.00718.83
8.2.60.0160.00318.77
8.2.50.0070.00318.75
8.2.40.0100.00018.78
8.2.30.0100.00018.84
8.2.20.0060.00318.83
8.2.10.0060.00319.23
8.2.00.0030.00619.00
8.1.340.0100.01117.51
8.1.330.0070.00821.88
8.1.320.0110.00715.92
8.1.310.0140.00416.14
8.1.300.0060.01016.17
8.1.290.0050.00530.84
8.1.280.0170.00325.92
8.1.270.0060.00323.99
8.1.260.0090.00026.35
8.1.250.0040.00428.09
8.1.240.0060.00318.68
8.1.230.0000.01018.57
8.1.220.0100.00018.62
8.1.210.0070.00319.79
8.1.200.0100.00018.39
8.1.190.0100.00018.51
8.1.180.0000.01018.34
8.1.170.0050.00518.65
8.1.160.0030.00718.84
8.1.150.0000.01022.28
8.1.140.0110.00020.30
8.1.130.0070.00318.55
8.1.120.0060.00318.63
8.1.110.0040.00718.55
8.1.100.0040.00818.29
8.1.90.0000.01018.39
8.1.80.0100.00018.59
8.1.70.0030.00618.78
8.1.60.0050.00518.68
8.1.50.0030.00718.50
8.1.40.0060.00318.76
8.1.30.0090.00018.99
8.1.20.0070.00318.82
8.1.10.0030.00718.63
8.1.00.0030.00718.69
8.0.300.0060.00317.81
8.0.290.0090.00017.88
8.0.280.0060.00317.82
8.0.270.0060.00317.86
8.0.260.0060.00317.82
8.0.250.0060.00317.96
8.0.240.0080.00018.01
8.0.230.0070.00318.18
8.0.220.0060.00317.80
8.0.210.0090.00017.74
8.0.200.0090.00018.01
8.0.190.0030.00617.77
8.0.180.0030.00717.82
8.0.170.0070.00317.77
8.0.160.0030.00717.76
8.0.150.0070.00317.67
8.0.140.0060.00317.83
8.0.130.0100.00017.80
8.0.120.0080.00317.57
8.0.110.0060.00317.85
8.0.100.0060.00317.75
8.0.90.0060.00317.93
8.0.80.0070.00317.66
8.0.70.0080.00317.61
8.0.60.0030.00717.88
8.0.50.0100.00017.69
8.0.30.0070.00317.83
8.0.20.0060.00318.03
8.0.10.0030.00618.13

preferences:
75.55 ms | 1232 KiB | 5 Q