3v4l.org

run code in 300+ PHP versions simultaneously
<?php function custom($arr, $newKey, $oldKey) { // if the value is not an array, then you have reached the deepest // point of the branch, so return the value if (!is_array($arr)) { return $arr; } $result = []; // empty array to hold copy of subject foreach ($arr as $key => $value) { // replace the key with the new key only if it is the old key $key = ($key === $oldKey) ? $newKey : $key; // add the value with the recursive call $result[$key] = custom($value, $newKey, $oldKey); } return $result; } $var = '[{"player":"Tiger Woods"},{"player":"Gary Player"}]'; $temp = json_decode($var, true); $temp = custom($temp, 'golfer','player'); print_r($temp);

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.00.0120.01019.82
8.4.150.0030.00014.05
8.4.140.0120.00917.71
8.4.130.0070.01317.66
8.4.120.0120.00720.62
8.4.110.0090.01222.39
8.4.100.0150.00617.73
8.4.90.0060.00322.39
8.4.80.0030.00619.31
8.4.70.0060.00817.85
8.4.60.0090.01218.73
8.4.50.0120.00920.70
8.4.40.0060.00319.54
8.4.30.0090.00922.58
8.4.20.0120.00820.79
8.4.10.0060.00319.55
8.3.280.0120.00918.64
8.3.270.0110.00916.48
8.3.260.0140.00516.47
8.3.250.0090.01221.09
8.3.240.0120.00816.72
8.3.230.0050.00416.51
8.3.220.0040.00418.85
8.3.210.0100.00916.76
8.3.200.0120.00716.33
8.3.190.0080.00617.08
8.3.180.0100.00916.59
8.3.170.0060.00916.91
8.3.160.0140.00420.11
8.3.150.0070.00016.53
8.3.140.0050.00316.58
8.3.130.0080.00018.51
8.3.120.0130.00618.88
8.3.110.0070.01316.44
8.3.100.0040.00416.61
8.3.90.0130.00716.47
8.3.80.0000.01018.18
8.3.70.0090.01218.31
8.3.60.0110.00718.43
8.3.50.0090.00718.18
8.3.40.0090.00618.71
8.3.30.0060.00918.71
8.3.20.0000.00921.76
8.3.10.0050.00321.90
8.3.00.0080.00023.66
8.2.290.0070.01122.27
8.2.280.0070.00918.62
8.2.270.0150.00617.05
8.2.260.0130.00618.50
8.2.250.0000.00818.30
8.2.240.0030.00618.70
8.2.230.0080.00020.94
8.2.220.0040.01224.06
8.2.210.0090.00926.77
8.2.200.0060.00318.16
8.2.190.0130.00616.58
8.2.180.0110.00718.27
8.2.170.0090.00922.96
8.2.160.0150.00021.21
8.2.150.0060.00324.18
8.2.140.0040.00424.66
8.2.130.0000.00826.16
8.2.120.0000.00821.07
8.2.110.0040.00721.07
8.2.100.0080.00417.91
8.2.90.0000.00818.16
8.2.80.0030.00618.34
8.2.70.0060.00317.75
8.2.60.0000.00817.75
8.2.50.0040.00418.10
8.2.40.0000.00720.64
8.2.30.0030.00519.33
8.2.20.0050.00218.06
8.2.10.0000.00719.39
8.2.00.0050.00319.38
8.1.330.0080.00322.09
8.1.320.0140.00516.44
8.1.310.0140.00318.38
8.1.300.0080.00019.53
8.1.290.0030.00618.88
8.1.280.0090.00625.92
8.1.270.0060.00324.02
8.1.260.0030.00626.35
8.1.250.0040.00428.09
8.1.240.0030.00622.55
8.1.230.0040.00720.89
8.1.220.0090.00017.77
8.1.210.0060.00318.77
8.1.200.0000.00817.35
8.1.190.0030.00517.23
8.1.180.0000.00818.10
8.1.170.0040.00418.49
8.1.160.0030.00518.93
8.1.150.0040.00418.91
8.1.140.0040.00418.91
8.1.130.0030.00320.20
8.1.120.0040.00417.48
8.1.110.0070.00017.43
8.1.100.0080.00017.48
8.1.90.0070.00017.38
8.1.80.0080.00017.49
8.1.70.0030.00317.38
8.1.60.0000.00817.48
8.1.50.0000.00717.56
8.1.40.0030.00617.47
8.1.30.0000.00917.61
8.1.20.0050.00317.64
8.1.10.0000.00717.55
8.1.00.0000.00717.38
8.0.300.0000.00820.04
8.0.290.0080.00016.63
8.0.280.0000.00718.41
8.0.270.0030.00317.23
8.0.260.0030.00318.37
8.0.250.0030.00317.00
8.0.240.0060.00016.91
8.0.230.0070.00016.84
8.0.220.0000.00816.89
8.0.210.0000.00716.95
8.0.200.0050.00317.04
8.0.190.0000.00716.93
8.0.180.0070.00016.94
8.0.170.0040.00416.81
8.0.160.0000.00816.96
8.0.150.0040.00416.76
8.0.140.0030.00516.95
8.0.130.0030.00313.32
8.0.120.0000.00816.82
8.0.110.0040.00416.79
8.0.100.0030.00516.75
8.0.90.0040.00416.86
8.0.80.0030.01316.86
8.0.70.0050.00316.75
8.0.60.0030.00616.90
8.0.50.0040.00416.91
8.0.30.0150.00717.22
8.0.20.0120.00616.89
8.0.10.0080.00016.91
8.0.00.0080.01016.92
7.4.330.0060.00015.55
7.4.320.0060.00016.59
7.4.300.0000.00616.50
7.4.290.0070.00016.60
7.4.280.0040.00416.59
7.4.270.0040.00416.61
7.4.260.0040.00216.61
7.4.250.0030.00316.48
7.4.240.0040.00316.53
7.4.230.0060.00316.73
7.4.220.0050.00316.49
7.4.210.0100.00616.58
7.4.200.0000.00716.39
7.4.160.0090.00616.42
7.4.130.0120.00916.43
7.4.120.0130.00716.73
7.4.110.0100.00716.34
7.4.100.0100.01016.59
7.4.90.0100.00716.50
7.4.80.0090.01019.39
7.4.70.0070.01016.52
7.4.60.0100.00716.60
7.4.50.0070.00716.40
7.4.40.0140.00916.36
7.4.00.0070.00914.80
7.3.330.0030.00313.20
7.3.320.0000.00613.16
7.3.310.0070.00016.48
7.3.300.0000.00716.26
7.3.290.0000.00716.42
7.3.280.0070.01116.36
7.3.260.0120.00816.52
7.3.240.0100.00716.53
7.3.230.0100.00716.38
7.3.210.0080.00916.44
7.3.200.0140.00316.54
7.3.190.0100.01016.31
7.3.180.0100.00616.64
7.3.170.0150.00616.65
7.3.160.0080.00816.44
7.3.120.0030.01315.05
7.3.110.0090.00914.75
7.3.100.0060.00915.15
7.3.90.0040.01214.98
7.3.80.0070.00714.87
7.3.70.0070.00314.77
7.3.60.0110.00514.86
7.3.50.0030.01014.70
7.3.40.0040.01114.68
7.3.30.0040.00714.82
7.3.20.0070.00516.68
7.3.10.0050.01016.77
7.3.00.0040.01516.67
7.2.330.0090.00916.57
7.2.320.0110.00716.79
7.2.310.0090.00916.77
7.2.300.0080.00916.41
7.2.290.0170.00316.44
7.2.250.0110.00415.06
7.2.240.0100.01015.10
7.2.230.0090.00615.24
7.2.220.0120.00314.98
7.2.210.0030.01014.98
7.2.200.0030.01014.87
7.2.190.0060.00515.09
7.2.180.0050.00815.06
7.2.170.0070.00615.01
7.2.160.0020.00915.11
7.2.150.0100.00516.95
7.2.140.0020.01416.82
7.2.130.0050.01316.91
7.2.120.0050.01016.90
7.2.110.0110.00816.86
7.2.100.0100.00716.98
7.2.90.0050.01016.79
7.2.80.0090.00916.81
7.2.70.0060.00816.87
7.2.60.0060.00816.90
7.2.50.0090.00716.99
7.2.40.0050.01017.04
7.2.30.0090.01217.01
7.2.20.0140.00316.88
7.2.10.0090.00816.94
7.2.00.0050.00816.94
7.1.330.0070.01116.00
7.1.320.0090.00915.70
7.1.310.0070.00415.67
7.1.300.0060.00615.81
7.1.290.0100.00315.80
7.1.280.0050.00615.73
7.1.270.0080.00315.70
7.1.260.0070.00715.72
7.1.250.0030.01215.76
7.1.240.0030.01016.00
7.1.230.0000.01215.80
7.1.220.0120.00315.82
7.1.210.0040.01215.91
7.1.200.0030.01215.86
7.1.190.0030.00915.80
7.1.180.0060.00615.77
7.1.170.0040.01515.83
7.1.160.0000.01815.84
7.1.150.0120.00315.46
7.1.140.0000.01815.69
7.1.130.0110.00415.71
7.1.120.0000.01315.89
7.1.110.0090.00615.60
7.1.100.0070.00715.91
7.1.90.0060.00615.79
7.1.80.0000.00915.68
7.1.70.0090.00315.86
7.1.60.0030.01015.59
7.1.50.0120.00315.95
7.1.40.0030.00616.06
7.1.30.0030.01015.69
7.1.20.0030.00916.00
7.1.10.0090.00315.77
7.1.00.0100.00315.59

preferences:
31.62 ms | 403 KiB | 5 Q