3v4l.org

run code in 300+ PHP versions simultaneously
<?php $structure = [ "a", "b" => [ "b1", "b2" => [ "b21", "b22" ] ] ]; $data = ['A', 'B1', 'B21', 'B22']; function alterKey(&$arr, $data) { foreach ($arr as $key => $val) { if (!is_array($val)) { $data_key = array_search(strtoupper($val), $data); $arr[$val] = $data[$data_key]; unset($arr[$key]); } else { $arr[$key] = alterKey($val, $data); } } ksort($arr); return $arr; } alterKey($structure, $data); echo '<pre>', print_r($structure);

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.70.0070.01116.25
8.3.60.0040.01418.55
8.3.50.0110.00522.00
8.3.40.0070.00718.81
8.3.30.0080.00818.59
8.3.20.0050.00221.63
8.3.10.0050.00320.07
8.3.00.0000.00722.39
8.2.190.0110.00716.58
8.2.180.0140.00418.18
8.2.170.0110.01122.96
8.2.160.0110.00319.50
8.2.150.0070.00324.18
8.2.140.0080.00024.66
8.2.130.0090.00026.16
8.2.120.0060.00326.16
8.2.110.0180.00419.24
8.2.100.0030.00917.78
8.2.90.0040.00420.45
8.2.80.0000.00818.05
8.2.70.0050.00317.91
8.2.60.0110.00017.83
8.2.50.0040.00418.10
8.2.40.0000.00819.42
8.2.30.0080.00019.32
8.2.20.0000.00718.16
8.2.10.0040.00419.17
8.2.00.0030.00319.28
8.1.280.0130.00325.92
8.1.270.0130.00620.60
8.1.260.0070.00026.35
8.1.250.0070.00028.09
8.1.240.0140.00719.21
8.1.230.0080.00420.90
8.1.220.0000.00817.74
8.1.210.0000.00819.08
8.1.200.0030.00517.22
8.1.190.0090.00017.35
8.1.180.0060.00318.10
8.1.170.0000.00818.64
8.1.160.0080.00018.88
8.1.150.0040.00418.92
8.1.140.0000.00720.89
8.1.130.0030.00320.00
8.1.120.0000.00717.48
8.1.110.0000.00717.41
8.1.100.0040.00417.46
8.1.90.0030.00617.29
8.1.80.0020.00517.49
8.1.70.0030.00317.48
8.1.60.0000.00817.45
8.1.50.0040.00417.40
8.1.40.0080.00017.41
8.1.30.0000.00817.61
8.1.20.0060.00617.64
8.1.10.0060.00317.43
8.1.00.0060.00317.49
8.0.300.0040.00419.88
8.0.290.0040.00416.75
8.0.280.0040.00418.44
8.0.270.0040.00418.48
8.0.260.0030.00320.06
8.0.250.0030.00316.84
8.0.240.0000.00716.96
8.0.230.0030.00316.99
8.0.220.0000.00816.79
8.0.210.0080.00016.75
8.0.200.0000.00716.95
8.0.190.0030.00617.01
8.0.180.0050.00316.86
8.0.170.0080.00016.78
8.0.160.0030.00616.94
8.0.150.0000.00716.92
8.0.140.0060.00316.87
8.0.130.0060.00013.25
8.0.120.0040.00416.85
8.0.110.0000.00716.80
8.0.100.0040.00416.84
8.0.90.0040.00416.78
8.0.80.0180.00316.77
8.0.70.0070.00016.95
8.0.60.0050.00216.76
8.0.50.0040.00416.91
8.0.30.0130.00617.05
8.0.20.0060.01717.10
8.0.10.0040.00417.07
8.0.00.0110.00916.85
7.4.330.0050.00015.55
7.4.320.0030.00316.51
7.4.300.0000.00716.49
7.4.290.0040.00416.41
7.4.280.0040.00416.61
7.4.270.0030.00316.59
7.4.260.0000.00716.55
7.4.250.0000.00816.46
7.4.240.0050.00216.45
7.4.230.0030.00316.40
7.4.220.0020.00516.48
7.4.210.0060.01016.57
7.4.200.0030.00316.63
7.4.130.0070.01416.35
7.4.120.0100.00616.57
7.4.110.0190.00716.52
7.4.100.0130.00416.29
7.4.90.0030.01516.45
7.4.80.0090.00919.39
7.4.70.0100.01016.65
7.4.60.0070.01016.70
7.4.50.0030.01016.41
7.4.40.0090.01216.29
7.4.10.0040.01414.61
7.4.00.0080.00915.03
7.3.330.0000.00813.21
7.3.320.0030.00313.22
7.3.310.0030.00316.25
7.3.300.0030.00316.27
7.3.290.0030.00316.36
7.3.280.0110.00316.41
7.3.260.0170.00916.39
7.3.240.0090.00816.41
7.3.230.0060.01616.50
7.3.210.0100.00716.57
7.3.200.0090.00616.34
7.3.190.0000.01616.56
7.3.180.0100.00716.12
7.3.170.0060.01016.66
7.3.160.0110.00716.34
7.3.130.0070.01314.55
7.3.120.0100.00714.65
7.3.110.0090.00714.68
7.3.100.0070.00614.74
7.3.90.0050.00814.80
7.3.80.0060.00714.77
7.3.70.0070.00714.82
7.3.60.0050.00814.70
7.3.50.0040.01314.78
7.3.40.0020.01114.60
7.3.30.0090.00614.87
7.3.20.0070.00816.04
7.3.10.0060.00916.12
7.3.00.0070.00716.15
7.2.330.0160.00616.75
7.2.320.0110.00716.80
7.2.310.0160.00716.84
7.2.300.0090.00916.77
7.2.290.0030.01316.47
7.2.260.0060.01314.72
7.2.250.0070.00914.90
7.2.240.0070.00815.07
7.2.230.0050.00915.11
7.2.220.0100.00615.09
7.2.210.0080.00715.04
7.2.200.0050.01015.02
7.2.190.0070.00915.02
7.2.180.0060.01015.07
7.2.170.0080.00415.00
7.2.160.0100.00615.09
7.2.150.0110.00216.26
7.2.140.0150.00316.20
7.2.130.0040.01016.11
7.2.120.0090.00416.25
7.2.110.0100.00516.37
7.2.100.0060.00816.25
7.2.90.0100.00616.27
7.2.80.0120.00416.39
7.2.70.0080.00816.26
7.2.60.0060.00916.29
7.2.50.0100.00616.32
7.2.40.0100.00716.24
7.2.30.0070.00816.36
7.2.20.0080.00816.23
7.2.10.0060.01016.30
7.2.00.0080.00516.33
7.1.330.0070.00715.72
7.1.320.0080.00615.85
7.1.310.0060.00815.71
7.1.300.0060.00815.36
7.1.290.0260.00415.23
7.1.280.0060.00615.27
7.1.270.0040.00915.35
7.1.260.0070.00815.31
7.1.250.0070.00715.24
7.1.240.0130.00015.82
7.1.230.0120.00315.62
7.1.220.0090.00315.62
7.1.210.0030.00915.63
7.1.200.0070.00715.42
7.1.190.0070.00315.61
7.1.180.0080.00415.71
7.1.170.0040.01115.59
7.1.160.0000.01515.50
7.1.150.0000.00915.69
7.1.140.0000.01415.65
7.1.130.0030.01015.77
7.1.120.0040.01215.67
7.1.110.0060.00615.91
7.1.100.0120.00015.50
7.1.90.0040.01115.50
7.1.80.0120.00415.66
7.1.70.0070.00715.64
7.1.60.0040.01215.64
7.1.50.0090.00615.80
7.1.40.0060.00315.76
7.1.30.0070.01015.66
7.1.20.0040.00415.80
7.1.10.0080.00015.94
7.1.00.0000.01115.53

preferences:
19.92 ms | 401 KiB | 5 Q