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(1); print_r($arr); print(2); print_r(getValueInNestedArray($arr, 'a', null)); print(3); print_r(getValueInNestedArray($arr, 'a.b.c.d', null)); print(4); 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.70.0070.00718.68
8.3.60.0160.00618.45
8.3.50.0120.00417.36
8.3.40.0090.00618.75
8.3.30.0040.01118.81
8.3.20.0050.00321.73
8.3.10.0080.00023.64
8.3.00.0040.00418.21
8.2.180.0090.00916.50
8.2.170.0060.00922.96
8.2.160.0100.00321.15
8.2.150.0090.00024.18
8.2.140.0040.00424.66
8.2.130.0040.00420.52
8.2.120.0080.00026.35
8.2.110.0150.00419.25
8.2.100.0000.01218.03
8.2.90.0000.00821.20
8.2.80.0060.00318.04
8.2.70.0040.00418.16
8.2.60.0060.00317.93
8.2.50.0000.00818.10
8.2.40.0000.00922.19
8.2.30.0060.00322.27
8.2.20.0040.00418.04
8.2.10.0030.00618.23
8.2.00.0040.00418.22
8.1.280.0090.00925.92
8.1.270.0050.00323.79
8.1.260.0080.00026.35
8.1.250.0040.00428.09
8.1.240.0100.00022.43
8.1.230.0050.00520.91
8.1.220.0040.00417.79
8.1.210.0000.00918.97
8.1.200.0050.00517.38
8.1.190.0000.00817.23
8.1.180.0050.00318.10
8.1.170.0040.00418.46
8.1.160.0040.00418.91
8.1.150.0080.00020.30
8.1.140.0030.00519.55
8.1.130.0040.00420.63
8.1.120.0070.00017.54
8.1.110.0050.00317.49
8.1.100.0040.00417.48
8.1.90.0000.00917.45
8.1.80.0000.00817.39
8.1.70.0040.00417.42
8.1.60.0030.00517.60
8.1.50.0040.00417.59
8.1.40.0070.00317.52
8.1.30.0040.00417.58
8.1.20.0050.00217.62
8.1.10.0080.00017.51
8.1.00.0050.00317.44
8.0.300.0050.00219.77
8.0.290.0000.00716.75
8.0.280.0040.00418.48
8.0.270.0000.00717.30
8.0.260.0000.00716.96
8.0.250.0040.00417.04
8.0.240.0060.00317.04
8.0.230.0030.00317.10
8.0.220.0050.00217.03
8.0.210.0030.00316.98
8.0.200.0030.00316.94
8.0.190.0000.00817.10
8.0.180.0090.00016.95
8.0.170.0050.00316.95
8.0.160.0040.00416.95
8.0.150.0070.00016.84
8.0.140.0070.00016.84
8.0.130.0050.00013.40
8.0.120.0040.00416.94
8.0.110.0030.00517.01
8.0.100.0040.00416.89
8.0.90.0000.00716.98
8.0.80.0140.00416.91
8.0.70.0000.00716.88
8.0.60.0030.00516.86
8.0.50.0040.00416.89
8.0.30.0110.00817.17
8.0.20.0120.00717.40
8.0.10.0000.00717.07
8.0.00.0090.00917.11
7.4.330.0050.00015.55
7.4.320.0000.00616.55
7.4.300.0070.00016.69
7.4.290.0100.00016.64
7.4.280.0000.00716.64
7.4.270.0000.00716.40
7.4.260.0000.00716.46
7.4.250.0000.00816.64
7.4.240.0000.00716.55
7.4.230.0030.00316.54
7.4.220.0150.00316.55
7.4.210.0070.00716.54
7.4.200.0000.00716.50
7.4.160.0070.00916.66
7.4.150.0110.01417.40
7.4.140.0110.00917.86
7.4.130.0120.01516.55
7.4.120.0130.01216.61
7.4.110.0070.01116.32
7.4.100.0100.00616.43
7.4.90.0140.00416.54
7.4.80.0080.01619.39
7.4.70.0120.00616.44
7.4.60.0060.01316.61
7.4.50.0030.01016.54
7.4.40.0150.00316.37
7.4.30.0050.01116.54
7.4.10.0090.00914.87
7.4.00.0060.01115.01
7.3.330.0000.00513.40
7.3.320.0030.00313.34
7.3.310.0030.00316.34
7.3.300.0080.00016.34
7.3.290.0090.00716.49
7.3.280.0060.00916.45
7.3.270.0090.00917.40
7.3.260.0140.00316.60
7.3.250.0100.01216.55
7.3.240.0130.00716.57
7.3.230.0180.00016.66
7.3.210.0120.00616.71
7.3.200.0080.00816.41
7.3.190.0100.00716.53
7.3.180.0130.00316.57
7.3.170.0060.01416.56
7.3.160.0030.01316.55
7.3.130.0100.00715.13
7.3.120.0100.00514.68
7.3.110.0080.01014.98
7.3.100.0050.01014.71
7.3.90.0080.01014.92
7.3.80.0010.01214.94
7.3.70.0070.00514.94
7.3.60.0060.00614.96
7.3.50.0090.00414.89
7.3.40.0090.00214.87
7.3.30.0080.00715.00
7.3.20.0100.00616.58
7.3.10.0020.01016.64
7.3.00.0110.00316.74
7.2.330.0140.00316.54
7.2.320.0170.00616.71
7.2.310.0080.00816.58
7.2.300.0080.01716.80
7.2.290.0100.00716.76
7.2.260.0030.00915.11
7.2.250.0100.00715.12
7.2.240.0060.01115.00
7.2.230.0060.00915.24
7.2.220.0050.01115.01
7.2.210.0080.00615.27
7.2.200.0030.01215.19
7.2.190.0050.00915.03
7.2.180.0070.00915.04
7.2.170.0030.01115.13
7.2.160.0030.00615.14
7.2.150.0030.01316.79
7.2.140.0030.01016.97
7.2.130.0060.00916.96
7.2.120.0000.01216.98
7.2.110.0110.00716.87
7.2.100.0060.00916.69
7.2.90.0060.00917.03
7.2.80.0060.00617.10
7.2.70.0000.01416.74
7.2.60.0070.00517.00
7.2.50.0040.01016.95
7.2.40.0000.01817.14
7.2.30.0100.00316.96
7.2.20.0090.00616.99
7.2.10.0090.00616.88
7.2.00.0040.00817.02
7.1.330.0020.01215.80
7.1.320.0040.01015.83
7.1.310.0060.00615.87
7.1.300.0090.00415.86
7.1.290.0080.00515.78
7.1.280.0020.00915.60
7.1.270.0050.01015.62
7.1.260.0050.00815.69
7.1.250.0060.00915.81
7.1.240.0040.01115.81
7.1.230.0030.00915.83
7.1.220.0070.00715.94
7.1.210.0040.01115.52
7.1.200.0060.00415.69
7.1.190.0060.00615.82
7.1.180.0040.00815.66
7.1.170.0030.00615.71
7.1.160.0060.00615.72
7.1.150.0060.00315.91
7.1.140.0090.00615.62
7.1.130.0150.00015.68
7.1.120.0000.01615.56
7.1.110.0040.01015.71
7.1.100.0110.00015.61
7.1.90.0030.01315.78
7.1.80.0040.01115.82
7.1.70.0060.00616.50
7.1.60.1820.01824.35
7.1.50.0700.00924.39
7.1.40.0110.00924.23
7.1.30.0110.01124.14
7.1.20.0330.01924.32
7.1.10.1650.00915.21
7.1.00.0070.00815.17
7.0.330.0080.00615.59
7.0.320.0070.00715.41
7.0.310.0070.00715.47
7.0.300.0060.01015.56
7.0.290.0030.00715.11
7.0.280.0060.00915.35
7.0.270.0040.01115.45
7.0.260.0040.00715.25
7.0.250.0000.01315.43
7.0.240.0030.00515.46
7.0.230.0030.01315.42
7.0.220.0030.01315.16
7.0.210.0040.01215.32
7.0.200.2110.00815.25
7.0.190.1180.01015.12
7.0.180.0120.00514.90
7.0.170.0030.01314.82
7.0.160.0050.01014.91
7.0.150.0050.01015.04
7.0.140.0200.00714.97
7.0.130.0050.00815.05
7.0.120.0250.00815.00
7.0.110.0070.00914.97
7.0.100.0180.00614.90
7.0.90.0070.00814.75
7.0.80.0080.01014.84
7.0.70.0050.01315.08
7.0.60.0070.00914.94
7.0.50.0070.00914.93
7.0.40.0090.00814.04
7.0.30.0030.01414.08
7.0.20.0080.01014.14
7.0.10.1230.01213.94
7.0.00.1070.01114.16
5.6.400.0150.00014.22
5.6.390.0100.00714.13
5.6.380.0100.00014.38
5.6.370.0030.01314.75
5.6.360.0130.00314.39
5.6.350.0060.00614.63
5.6.340.0160.00014.30
5.6.330.0030.01014.09
5.6.320.0000.01414.11
5.6.310.0100.00714.41
5.6.300.0060.00614.47
5.6.290.0090.00614.80
5.6.280.0000.01114.63
5.6.270.0070.00714.13
5.6.260.0070.00714.23
5.6.250.0120.00314.11
5.6.240.0080.00614.20
5.6.230.0030.00714.30
5.6.220.0060.00314.58
5.6.210.0030.00814.48
5.6.200.0070.00714.36
5.6.190.0060.00314.24
5.6.180.0070.00314.55
5.6.170.0070.00714.27
5.6.160.0040.01114.23
5.6.150.0070.00714.50
5.6.140.0070.00714.43
5.6.130.0090.00914.59
5.6.120.0070.00714.32
5.6.110.0000.01214.36
5.6.100.0030.01014.17
5.6.90.0030.00714.54
5.6.80.0060.00614.12
5.6.70.0030.00914.21
5.6.60.0000.00914.16
5.6.50.0000.01414.31
5.6.40.0030.00914.44
5.6.30.0070.00714.25
5.6.20.0100.00314.20
5.6.10.0050.00514.30
5.6.00.0080.00014.20

preferences:
51.97 ms | 401 KiB | 5 Q