3v4l.org

run code in 300+ PHP versions simultaneously
<?php function setValueInNestedArray(&$array, $path, $value, $delimiter = '.'){ $pathSegments = explode($delimiter, $path); $currentNode = &$array; foreach($pathSegments as $pathSegment) { if(!is_array($currentNode[$pathSegment])) { $currentNode[$pathSegment] = []; } $currentNode = &$currentNode[$pathSegment]; } $currentNode = $value; } function getValueInNestedArray($array, $path, $defaultValue, $delimiter = '.'){ $pathSegments = explode($delimiter, $path); $pathExists = true; $currentNode = &$array; foreach($pathSegments as $pathSegment) { if(is_array($currentNode[$pathSegment])) { $currentNode = &$currentNode[$pathSegment]; } else { $pathExists = false; } } return $pathExists ? $currentNode : $defaultValue; } $arr =[]; setValueInNestedArray($arr, 'a.b.c.d', 'e'); print_r($arr); print_r(getValueInNestedArray($arr, 'a', null)); print_r(getValueInNestedArray($arr, 'a.b.c.d', null)); print_r(getValueInNestedArray($arr, 'e.f.g', null)); ?>

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.0060.00918.55
8.3.50.0070.00716.61
8.3.40.0070.00719.11
8.3.30.0040.01118.79
8.3.20.0030.00623.71
8.3.10.0000.00823.51
8.3.00.0050.00318.16
8.2.180.0100.01016.63
8.2.170.0130.00722.96
8.2.160.0070.00721.25
8.2.150.0040.00424.18
8.2.140.0050.00324.66
8.2.130.0040.00420.39
8.2.120.0090.00026.35
8.2.110.0030.00619.22
8.2.100.0070.01017.72
8.2.90.0040.00419.10
8.2.80.0050.00317.97
8.2.70.0040.00417.75
8.2.60.0090.00018.05
8.2.50.0050.00318.10
8.2.40.0000.00822.29
8.2.30.0040.00422.10
8.2.20.0040.00418.20
8.2.10.0070.00018.08
8.2.00.0030.00518.02
8.1.280.0000.01525.92
8.1.270.0060.00324.66
8.1.260.0000.00726.35
8.1.250.0060.00328.09
8.1.240.0060.00322.06
8.1.230.0000.01119.00
8.1.220.0080.00017.74
8.1.210.0040.00418.77
8.1.200.0040.00417.48
8.1.190.0030.00617.23
8.1.180.0000.00818.10
8.1.170.0050.00318.71
8.1.160.0050.00318.95
8.1.150.0070.00020.20
8.1.140.0040.00419.47
8.1.130.0070.00020.27
8.1.120.0040.00417.43
8.1.110.0040.00417.38
8.1.100.0040.00417.42
8.1.90.0000.00817.48
8.1.80.0050.00317.50
8.1.70.0000.00717.53
8.1.60.0040.00417.57
8.1.50.0040.00417.59
8.1.40.0040.00417.61
8.1.30.0000.00717.71
8.1.20.0000.00817.63
8.1.10.0040.00417.58
8.1.00.0060.00317.48
8.0.300.0070.00018.77
8.0.290.0000.00716.75
8.0.280.0040.00418.46
8.0.270.0070.00017.19
8.0.260.0000.00618.39
8.0.250.0030.00317.03
8.0.240.0040.00416.92
8.0.230.0030.00316.93
8.0.220.0070.00017.04
8.0.210.0000.00717.00
8.0.200.0040.00416.90
8.0.190.0000.01017.02
8.0.180.0000.00717.01
8.0.170.0040.00417.02
8.0.160.0040.00416.89
8.0.150.0000.00816.94
8.0.140.0040.00416.82
8.0.130.0060.00313.50
8.0.120.0040.00416.95
8.0.110.0070.00017.03
8.0.100.0070.00017.00
8.0.90.0040.00416.83
8.0.80.0060.00917.00
8.0.70.0040.00416.84
8.0.60.0040.00417.01
8.0.50.0040.00417.02
8.0.30.0120.00717.18
8.0.20.0120.00717.40
8.0.10.0040.00416.90
8.0.00.0090.00816.71
7.4.330.0000.00515.55
7.4.320.0060.00016.52
7.4.300.0030.00316.58
7.4.290.0000.00916.50
7.4.280.0000.00716.61
7.4.270.0070.00016.44
7.4.260.0030.00716.59
7.4.250.0000.00816.48
7.4.240.0030.00316.62
7.4.230.0030.00316.37
7.4.220.0070.02016.63
7.4.210.0030.01016.73
7.4.200.0070.00016.52
7.4.160.0120.00916.52
7.4.150.0120.00617.40
7.4.140.0160.00517.86
7.4.130.0040.02016.62
7.4.120.0080.01416.61
7.4.110.0130.00316.59
7.4.100.0090.01216.42
7.4.90.0080.00816.57
7.4.80.0120.01219.39
7.4.70.0100.00716.36
7.4.60.0000.01616.75
7.4.50.0060.00916.68
7.4.40.0100.00616.33
7.4.30.0110.00716.52
7.4.10.0100.01015.12
7.4.00.0060.01114.91
7.3.330.0050.00013.42
7.3.320.0030.00313.32
7.3.310.0040.00416.49
7.3.300.0000.00716.33
7.3.290.0060.01016.48
7.3.280.0080.00916.43
7.3.270.0140.00417.40
7.3.260.0140.00616.48
7.3.250.0100.00816.49
7.3.240.0090.01016.38
7.3.230.0120.00816.43
7.3.210.0090.01316.46
7.3.200.0140.01016.74
7.3.190.0060.01216.54
7.3.180.0140.00716.46
7.3.170.0150.00316.47
7.3.160.0000.01616.46
7.3.130.0030.01414.88
7.3.120.0170.00015.04
7.3.110.0070.01114.91
7.3.100.0110.00414.98
7.3.90.0030.01015.04
7.3.80.0030.00814.70
7.3.70.0080.00614.96
7.3.60.0030.00614.79
7.3.50.0040.00814.90
7.3.40.0060.00914.80
7.3.30.0150.00014.96
7.3.20.0030.01016.48
7.3.10.0060.00616.44
7.3.00.0090.00816.58
7.2.330.0100.00716.91
7.2.320.0050.01916.76
7.2.310.0030.01316.69
7.2.300.0180.00016.71
7.2.290.0030.01416.56
7.2.260.0070.01015.04
7.2.250.0000.01615.18
7.2.240.0110.00715.14
7.2.230.0070.01015.20
7.2.220.0070.01014.71
7.2.210.0000.01215.15
7.2.200.0050.00515.26
7.2.190.0040.00715.00
7.2.180.0110.00015.18
7.2.170.0000.01414.92
7.2.160.0070.01014.91
7.2.150.0000.01316.91
7.2.140.0060.00916.98
7.2.130.0040.01316.77
7.2.120.0080.00916.90
7.2.110.0070.01116.71
7.2.100.0080.00817.08
7.2.90.0090.00417.04
7.2.80.0120.00616.90
7.2.70.0120.00616.73
7.2.60.0080.00816.90
7.2.50.0040.01016.85
7.2.40.0110.00317.01
7.2.30.0040.00917.05
7.2.20.0090.00516.94
7.2.10.0050.00617.09
7.2.00.0070.00616.93
7.1.330.0120.00315.65
7.1.320.0120.00316.04
7.1.310.0000.01615.66
7.1.300.0030.01215.52
7.1.290.0060.01015.52
7.1.280.0060.01015.59
7.1.270.0060.00615.93
7.1.260.0100.00715.72
7.1.250.0060.01015.60
7.1.240.0070.00715.98
7.1.230.0090.00615.61
7.1.220.0000.01315.55
7.1.210.0030.00715.82
7.1.200.0030.01015.69
7.1.190.0060.00615.75
7.1.180.0000.01315.55
7.1.170.0030.01015.64
7.1.160.0080.00615.93
7.1.150.0070.00315.55
7.1.140.0030.01515.56
7.1.130.0030.01315.81
7.1.120.0080.00615.98
7.1.110.0030.00715.57
7.1.100.0060.01015.98
7.1.90.0040.01415.93
7.1.80.0070.00715.54
7.1.70.0020.01316.27
7.1.60.0130.00924.57
7.1.50.0510.00824.41
7.1.40.1200.00624.33
7.1.30.0930.01124.17
7.1.20.0130.01224.35
7.1.10.0060.00915.28
7.1.00.0220.01215.31
7.0.330.0040.00815.46
7.0.320.0090.00315.30
7.0.310.0000.01515.16
7.0.300.0070.00715.29
7.0.290.0120.00315.43
7.0.280.0000.01215.41
7.0.270.0070.00715.42
7.0.260.0030.01215.42
7.0.250.0100.00315.50
7.0.240.0070.00715.40
7.0.230.0070.00715.25
7.0.220.0100.00315.41
7.0.210.0070.00715.14
7.0.200.0100.00715.24
7.0.190.0930.01115.16
7.0.180.0100.01214.90
7.0.170.0070.00714.96
7.0.160.0080.01014.94
7.0.150.1070.01014.98
7.0.140.0050.01014.89
7.0.130.0890.00715.16
7.0.120.0930.01115.16
7.0.110.0770.01014.87
7.0.100.0970.01314.82
7.0.90.0070.01114.92
7.0.80.0080.00815.06
7.0.70.0060.00814.93
7.0.60.0650.01014.84
7.0.50.0720.00815.16
7.0.40.0520.01114.05
7.0.30.0530.01114.19
7.0.20.0850.01414.00
7.0.10.1050.01013.93
7.0.00.0920.01014.02
5.6.400.0030.01614.57
5.6.390.0070.00414.10
5.6.380.0070.00314.19
5.6.370.0000.01514.67
5.6.360.0040.01114.60
5.6.350.0120.00014.65
5.6.340.0040.01114.70
5.6.330.0060.01214.54
5.6.320.0040.00814.11
5.6.310.0000.01314.33
5.6.300.0030.00914.86
5.6.290.0070.01114.25
5.6.280.0060.00914.84
5.6.270.0040.00714.20
5.6.260.0060.00314.27
5.6.250.0110.00314.27
5.6.240.0060.00914.72
5.6.230.0070.00714.05
5.6.220.0040.01214.63
5.6.210.0080.00414.71
5.6.200.0080.00414.32
5.6.190.0080.00814.46
5.6.180.0100.00714.45
5.6.170.0090.00614.51
5.6.160.0040.01514.20
5.6.150.0060.00614.59
5.6.140.0030.01014.43
5.6.130.0080.00814.49
5.6.120.0000.01614.25
5.6.110.0060.00614.52
5.6.100.0100.00314.52
5.6.90.0060.00914.29
5.6.80.0070.00714.09
5.6.70.0070.00714.02
5.6.60.0130.00014.31
5.6.50.0040.01214.13
5.6.40.0060.00914.46
5.6.30.0100.00014.45
5.6.20.0060.00314.48
5.6.10.0090.00914.30
5.6.00.0000.01314.25

preferences:
40.63 ms | 400 KiB | 5 Q