3v4l.org

run code in 300+ PHP versions simultaneously
<?php function moveKeyBefore($arr, $find, $move) { if (!isset($arr[$find], $arr[$move])) { return $arr; } $elem = [$move=>$arr[$move]]; // cache the element to be moved $start = array_splice($arr, 0, array_search($find, array_keys($arr))); unset($start[$move]); // only important if $move is in $start return $start + $elem + $arr; } $arr = ['foo1'=>'bar', 'foo2'=>'buzz', 'foo3'=>'bazz']; var_export(moveKeyBefore($arr, 'foo3', 'foo1'));

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.0160.00318.31
8.3.50.0080.00818.29
8.3.40.0180.00018.61
8.3.30.0180.00018.62
8.3.20.0080.00020.71
8.3.10.0040.00423.52
8.3.00.0000.00822.37
8.2.180.0110.00418.18
8.2.170.0110.00422.96
8.2.160.0030.01322.12
8.2.150.0060.00324.18
8.2.140.0050.00324.66
8.2.130.0110.00421.05
8.2.120.0000.00826.35
8.2.110.0030.00722.17
8.2.100.0200.00318.36
8.2.90.0090.01018.36
8.2.80.0140.00518.21
8.2.70.0150.00518.12
8.2.60.0130.00518.30
8.2.50.0140.00618.27
8.2.40.0110.00519.53
8.2.30.0090.00518.69
8.2.20.0150.00218.45
8.2.10.0110.00518.91
8.2.00.0130.00418.48
8.1.280.0070.01025.92
8.1.270.0050.00320.24
8.1.260.0040.00426.35
8.1.250.0070.00028.09
8.1.240.0040.00820.81
8.1.230.0090.00619.95
8.1.220.0130.00418.11
8.1.210.0150.00418.61
8.1.200.0190.00517.89
8.1.190.0150.00417.89
8.1.180.0140.00318.27
8.1.170.0140.00518.51
8.1.160.0230.00118.56
8.1.150.0150.00418.61
8.1.140.0120.00519.09
8.1.130.0110.00718.09
8.1.120.0130.00218.02
8.1.110.0140.00218.00
8.1.100.0120.00318.01
8.1.90.0120.00518.00
8.1.80.0140.00318.01
8.1.70.0140.00417.97
8.1.60.0120.00618.10
8.1.50.0140.00517.80
8.1.40.0170.00317.96
8.1.30.0150.00518.04
8.1.20.0130.00717.97
8.1.10.0130.00717.94
8.1.00.0150.00517.89
8.0.300.0160.00119.00
8.0.290.0160.00417.60
8.0.280.0170.00518.25
8.0.270.0100.00717.87
8.0.260.0120.00417.77
8.0.250.0130.00217.57
8.0.240.0070.00817.59
8.0.230.0130.00317.60
8.0.220.0120.00417.56
8.0.210.0090.00617.58
8.0.200.0090.00517.56
8.0.190.0150.00317.62
8.0.180.0110.00517.50
8.0.170.0110.00517.46
8.0.160.0100.00417.47
8.0.150.0090.00717.43
8.0.140.0110.00417.45
8.0.130.0130.00316.71
8.0.120.0130.00217.39
8.0.110.0110.00617.43
8.0.100.0110.00417.34
8.0.90.0100.00517.33
8.0.80.0120.00417.35
8.0.70.0100.00517.29
8.0.60.0090.00417.29
8.0.50.0090.00517.29
8.0.30.0110.00617.32
8.0.20.0150.00517.32
8.0.10.0120.00517.46
8.0.00.0110.00617.19
7.4.330.0090.00316.15
7.4.320.0120.00417.24
7.4.300.0080.00717.24
7.4.290.0120.00517.16
7.4.280.0130.00317.17
7.4.270.0110.00517.15
7.4.260.0140.00317.13
7.4.250.0110.00517.08
7.4.240.0140.00217.09
7.4.230.0130.00216.93
7.4.220.0070.00717.00
7.4.210.0090.00616.92
7.4.200.0080.00516.98
7.4.190.0130.00317.15
7.4.180.0110.00517.15
7.4.160.0100.00616.80
7.4.150.0060.00616.92
7.4.140.0110.00417.20
7.4.130.0100.00716.73
7.4.120.0110.00616.84
7.4.110.0110.00516.76
7.4.100.0120.00516.76
7.4.90.0100.00616.78
7.4.80.0100.00717.09
7.4.70.0100.00616.79
7.4.60.0110.00416.76
7.4.50.0100.00716.81
7.4.40.0100.00616.74
7.4.30.0100.00616.85
7.4.20.0090.00716.81
7.4.10.0100.00716.75
7.4.00.0100.00616.59
7.3.330.0120.00416.33
7.3.320.0100.00616.33
7.3.310.0110.00516.91
7.3.300.0110.00416.82
7.3.290.0100.00516.82
7.3.280.0110.00816.67
7.3.270.0100.00616.84
7.3.260.0070.00916.69
7.3.250.0120.00516.78
7.3.240.0100.00616.64
7.3.230.0120.00816.69
7.3.220.0110.00616.64
7.3.210.0110.00716.61
7.3.200.0120.00616.69
7.3.190.0100.00716.72
7.3.180.0090.00916.63
7.3.170.0100.00716.63
7.3.160.0110.00716.60
7.3.150.0120.00616.63
7.3.140.0120.00616.61
7.3.130.0110.00616.61
7.3.120.0130.00816.46
7.3.110.0110.00716.35
7.3.100.0100.00816.51
7.3.90.0120.00716.57
7.3.80.0120.00716.47
7.3.70.0100.00716.34
7.3.60.0130.00516.41
7.3.50.0110.00816.34
7.3.40.0120.00716.26
7.3.30.0110.00816.12
7.3.20.0180.00616.36
7.3.10.0150.00716.34
7.3.00.0170.00716.41
7.2.340.0130.00716.81
7.2.330.0120.00816.84
7.2.320.0120.00716.80
7.2.310.0130.00816.72
7.2.300.0150.00616.84
7.2.290.0130.00716.79
7.2.280.0170.00416.85
7.2.270.0120.00816.84
7.2.260.0120.00816.78
7.2.250.0130.00816.65
7.2.240.0140.00716.63
7.2.230.0140.00716.62
7.2.220.0130.00816.57
7.2.210.0130.00716.62
7.2.200.0150.00616.53
7.2.190.0140.00716.54
7.2.180.0130.00716.55
7.2.170.0140.00816.45
7.2.160.0120.00816.32
7.2.150.0180.00816.62
7.2.140.0180.00716.59
7.2.130.0180.00816.66
7.2.120.0200.01016.62
7.2.110.0180.00916.67
7.2.100.0190.00716.60
7.2.90.0180.00716.63
7.2.80.0220.00616.53
7.2.70.0180.00716.64
7.2.60.0170.00816.58
7.2.50.0170.00616.64
7.2.40.0180.00716.67
7.2.30.0180.00816.61
7.2.20.0180.00616.62
7.2.10.0160.00816.64
7.2.00.0160.00716.63
7.1.330.0140.00716.10
7.1.320.0160.00616.11
7.1.310.0150.00516.10
7.1.300.0130.00715.89
7.1.290.0160.00715.89
7.1.280.0140.00715.74
7.1.270.0190.00715.62
7.1.260.0170.00615.56
7.1.250.0140.00815.62
7.1.240.0120.00816.25
7.1.230.0120.00716.23
7.1.220.0140.00616.28
7.1.210.0140.00916.28
7.1.200.0130.00616.34
7.1.190.0130.00516.24
7.1.180.0140.00616.22
7.1.170.0190.00716.21
7.1.160.0180.00616.21
7.1.150.0140.00716.28
7.1.140.0150.00616.26
7.1.130.0160.00616.28
7.1.120.0140.00716.24
7.1.110.0140.00716.26
7.1.100.0210.00816.23
7.1.90.0150.00516.27
7.1.80.0150.00616.31
7.1.70.0160.00516.23
7.1.60.0140.00816.31
7.1.50.0160.00516.26
7.1.40.0150.00516.32
7.1.30.0130.00816.31
7.1.20.0150.00816.29
7.1.10.0130.00816.28
7.1.00.0150.00616.20

preferences:
55.52 ms | 400 KiB | 5 Q