3v4l.org

run code in 300+ PHP versions simultaneously
<?php function algorithm_a() { $data = [ 'city' => 'Lexington', 'name' => 'Mike Tyson', 'occupation' => 'Hot Dog Vendor', 'state' => 'KY', 'address' => '1009 Nicholasville Road', 'ZIP' => '40526' ]; $order = [ 'name', 'city', 'state' ]; $filtered = array_intersect_key( $data, array_flip($order) ); $ordered = array_merge( array_flip($order), $filtered ); return $ordered; } function algorithm_b() { $data = [ 'city' => 'Lexington', 'name' => 'Mike Tyson', 'occupation' => 'Hot Dog Vendor', 'state' => 'KY', 'address' => '1009 Nicholasville Road', 'ZIP' => '40526' ]; $order = [ 'name', 'city', 'state' ]; $result = array(); foreach($order as $column_name) { $result[$column_name] = $data[$column_name]; } return $result; } $result = algorithm_b(); var_dump($result);

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.01016.37
8.3.50.0080.01022.82
8.3.40.0110.00418.66
8.3.30.0070.00719.09
8.3.20.0080.00020.34
8.3.10.0040.00420.59
8.3.00.0060.00320.81
8.2.180.0170.00318.41
8.2.170.0090.00922.96
8.2.160.0030.01020.47
8.2.150.0030.00624.18
8.2.140.0080.00024.66
8.2.130.0040.00426.16
8.2.120.0060.00319.48
8.2.110.0060.00319.45
8.2.100.0110.00018.03
8.2.90.0050.00319.17
8.2.80.0050.00317.97
8.2.70.0060.00317.63
8.2.60.0000.00817.79
8.2.50.0050.00518.07
8.2.40.0030.00618.22
8.2.30.0070.00319.59
8.2.20.0040.00417.69
8.2.10.0080.00018.04
8.2.00.0030.00617.80
8.1.280.0140.00425.92
8.1.270.0130.00723.97
8.1.260.0080.00026.35
8.1.250.0080.00028.09
8.1.240.0040.01422.54
8.1.230.0040.00720.97
8.1.220.0050.00318.77
8.1.210.0050.00319.00
8.1.200.0060.00317.35
8.1.190.0030.00517.41
8.1.180.0050.00318.10
8.1.170.0000.00918.59
8.1.160.0050.00318.90
8.1.150.0040.00418.86
8.1.140.0000.00817.46
8.1.130.0030.00517.75
8.1.120.0070.00017.38
8.1.110.0040.00417.44
8.1.100.0000.00717.49
8.1.90.0000.00717.37
8.1.80.0000.00817.45
8.1.70.0070.00017.38
8.1.60.0000.00817.60
8.1.50.0030.00617.42
8.1.40.0040.00717.42
8.1.30.0030.00617.57
8.1.20.0050.00217.59
8.1.10.0080.00017.57
8.1.00.0020.00517.35
8.0.300.0000.00719.93
8.0.290.0070.00017.04
8.0.280.0000.00718.33
8.0.270.0000.00817.31
8.0.260.0030.00317.28
8.0.250.0000.00717.05
8.0.240.0060.00316.99
8.0.230.0050.00316.93
8.0.220.0000.00716.81
8.0.210.0070.00016.98
8.0.200.0000.00616.94
8.0.190.0070.00016.88
8.0.180.0000.00816.82
8.0.170.0050.00316.81
8.0.160.0030.00516.98
8.0.150.0050.00316.86
8.0.140.0000.00816.86
8.0.130.0040.00413.37
8.0.120.0000.00916.90
8.0.110.0000.00716.77
8.0.100.0000.00716.78
8.0.90.0040.00416.89
8.0.80.0180.00316.86
8.0.70.0000.00816.95
8.0.60.0050.00316.85
8.0.50.0000.00816.73
8.0.30.0120.00617.11
8.0.20.0130.00917.40
8.0.10.0070.00017.06
8.0.00.0100.01116.92
7.4.330.0060.00015.12
7.4.320.0000.00616.52
7.4.300.0030.00316.62
7.4.290.0000.00716.61
7.4.280.0070.00016.51
7.4.270.0030.00316.46
7.4.260.0030.00316.59
7.4.250.0070.00016.59
7.4.240.0020.00516.62
7.4.230.0070.00016.47
7.4.220.0110.01016.46
7.4.210.0070.01416.61
7.4.200.0000.00716.51
7.4.160.0070.01016.42
7.4.150.0060.01217.40
7.4.140.0080.01017.86
7.4.130.0100.00716.48
7.4.120.0070.01016.56
7.4.110.0060.01216.52
7.4.100.0070.01316.50
7.4.90.0060.01116.57
7.4.80.0110.01319.39
7.4.70.0100.00716.36
7.4.60.0110.01116.54
7.4.50.0070.00016.42
7.4.40.0080.01616.56
7.4.30.0090.00916.35
7.4.00.0030.00515.02
7.3.330.0000.00613.32
7.3.320.0030.00313.34
7.3.310.0070.00016.36
7.3.300.0060.00016.27
7.3.290.0060.01116.38
7.3.280.0060.01116.37
7.3.270.0030.01517.40
7.3.260.0120.00616.38
7.3.250.0060.01216.38
7.3.240.0120.00616.59
7.3.230.0160.00916.67
7.3.210.0030.01516.39
7.3.200.0060.01219.39
7.3.190.0100.01016.41
7.3.180.0130.00316.40
7.3.170.0090.00616.52
7.3.160.0060.00916.41
7.3.10.0170.00016.20
7.3.00.0000.01016.23
7.2.330.0130.00616.54
7.2.320.0120.00416.61
7.2.310.0060.01216.79
7.2.300.0130.01016.74
7.2.290.0080.00816.55
7.2.130.0070.00716.93
7.2.120.0110.00717.11
7.2.110.0120.00616.68
7.2.100.0200.00016.76
7.2.90.0070.00716.65
7.2.80.0100.01016.97
7.2.70.0120.00317.04
7.2.60.0030.00916.81
7.2.50.0060.01316.75
7.2.40.0270.00516.82
7.2.30.0090.00516.50
7.2.20.0060.00916.71
7.2.10.0090.00916.75
7.2.00.0110.00618.11
7.1.250.0080.00415.89
7.1.100.0060.00918.24
7.1.70.0000.01016.94
7.1.60.0130.01019.34
7.1.50.0030.00916.96
7.1.00.0030.07722.45
7.0.200.0080.00416.82
7.0.140.0000.07322.00
7.0.60.0100.08019.93
7.0.50.0170.07317.88
7.0.40.0100.05720.18
7.0.30.0170.04320.24
7.0.20.0270.07720.22
7.0.10.0170.08020.20
7.0.00.0070.08320.29
5.6.280.0030.07320.90
5.6.210.0100.08020.51
5.6.200.0070.07718.18
5.6.190.0070.04720.67
5.6.180.3430.04020.39
5.6.170.0130.05020.51
5.6.160.0070.07720.50
5.6.150.0070.07318.18
5.6.140.0100.08018.14
5.6.130.0170.06018.18
5.6.120.0070.04020.88
5.6.110.0200.07321.02
5.6.100.0100.03721.02
5.6.90.0070.07020.99
5.6.80.0130.06720.41
5.6.70.4030.03320.39
5.5.350.0130.06020.45
5.5.340.0170.07717.99
5.5.330.0100.05320.25
5.5.320.0400.03720.27
5.5.310.0300.06320.35
5.5.300.0100.08017.95
5.5.290.0100.07717.96
5.5.280.0100.04720.65
5.5.270.0030.04020.78
5.5.260.0100.07320.80
5.5.250.0170.06720.69
5.5.240.0070.05320.16
5.4.450.0400.03737.84
5.4.440.0400.04737.83
5.4.430.0100.03737.83
5.4.420.0530.04737.83
5.4.410.0330.04337.77
5.4.400.0370.03335.77
5.4.390.0400.04334.18
5.4.380.0430.04732.09
5.4.370.0200.04730.13
5.4.360.0130.03729.28
5.4.350.0130.04314.03
5.4.340.0230.03713.95
5.4.320.0270.03314.25
5.4.310.0130.05314.21
5.4.300.0170.04014.27
5.4.290.0170.04014.26
5.4.280.0170.04714.18
5.4.270.0200.05014.11
5.4.260.0170.04014.32
5.4.250.0330.03014.14
5.4.240.0200.03714.28
5.4.230.0130.03714.39
5.4.220.0100.04714.16
5.4.210.0130.04014.05
5.4.200.0100.05014.18
5.4.190.0200.03014.14
5.4.180.0170.04714.18
5.4.170.0100.05714.16
5.4.160.0270.03014.16
5.4.150.0170.03714.16
5.4.140.0100.05714.07
5.4.130.0070.04713.81
5.4.120.0100.04313.76
5.4.110.0100.04313.76
5.4.100.0170.04713.77
5.4.90.0200.04013.76
5.4.80.0200.03313.93
5.4.70.0100.04313.71
5.4.60.0170.04013.77
5.4.50.0200.03313.80
5.4.40.0130.04013.71
5.4.30.0130.04013.74
5.4.20.0170.04013.76
5.4.10.0170.04013.70
5.4.00.0200.04013.23
5.3.290.0170.04014.64
5.3.280.0130.04014.55
5.3.270.0170.03714.56
5.3.260.0100.04314.59
5.3.250.0170.04014.55
5.3.240.0270.04714.63
5.3.230.0230.04714.75
5.3.220.0100.06014.51
5.3.210.0130.04714.61
5.3.200.0130.04014.67
5.3.190.0270.03714.54
5.3.180.0130.04314.50
5.3.170.0230.04014.61
5.3.160.0170.03314.59
5.3.150.0100.04014.48
5.3.140.0130.03714.60
5.3.130.0130.04014.47
5.3.120.0130.04014.68
5.3.110.0100.04314.58
5.3.100.0200.04313.96
5.3.90.0200.04014.07
5.3.80.0170.05313.96
5.3.70.0170.04014.08
5.3.60.0270.03714.11
5.3.50.0170.04013.89
5.3.40.0170.04013.97
5.3.30.0170.03713.89
5.3.20.0270.02713.65
5.3.10.0170.03313.69
5.3.00.0130.04013.61
5.2.170.0100.03711.07
5.2.160.0100.04011.17
5.2.150.0070.05011.17
5.2.140.0100.04311.11
5.2.130.0130.03311.16
5.2.120.0170.02711.06
5.2.110.0200.03011.16
5.2.100.0230.02711.08
5.2.90.0100.04311.27
5.2.80.0270.04011.13
5.2.70.0100.04311.16
5.2.60.0130.03010.97
5.2.50.0170.02711.15
5.2.40.0100.03010.97
5.2.30.0130.03711.04
5.2.20.0070.03310.99
5.2.10.0100.03310.89
5.2.00.0170.03010.76
5.1.60.0100.0279.96
5.1.50.0000.03310.02
5.1.40.0130.02310.11
5.1.30.0030.04010.51
5.1.20.0230.02710.34
5.1.10.0130.02710.19
5.1.00.0030.03010.02
5.0.50.0100.0238.51
5.0.40.0070.0178.34
5.0.30.0100.0278.30
5.0.20.0100.0238.34
5.0.10.0030.0238.19
5.0.00.0030.0338.07
4.4.90.0030.0205.82
4.4.80.0000.0205.84
4.4.70.0000.0205.92
4.4.60.0000.0205.85
4.4.50.0070.0135.82
4.4.40.0070.0235.79
4.4.30.0000.0205.90
4.4.20.0030.0235.98
4.4.10.0100.0175.99
4.4.00.0000.0305.85
4.3.110.0000.0205.83
4.3.100.0070.0135.75
4.3.90.0070.0135.75
4.3.80.0130.0205.75
4.3.70.0100.0105.72
4.3.60.0000.0205.72
4.3.50.0030.0205.70
4.3.40.0070.0275.72
4.3.30.0070.0134.52
4.3.20.0030.0134.49
4.3.10.0000.0174.61
4.3.00.0030.01728.21

preferences:
52.36 ms | 401 KiB | 5 Q