3v4l.org

run code in 500+ PHP versions simultaneously
<?php $arr = [['ID' => 1, 'Name' => 'My Name', 'GroupLocations' => [['GroupId' => 111, 'LocationId' => 222, 'Location' => ['Name' => 'MyLocation', 'Street1' => '555 Somewhere Lane']]]]]; $results = []; // the container for the search result(s) $key = 'Name'; // the key we are looking for findKey($arr, $key, $results); // invoke the search function /* NEW */ $count = count($results); for($i = 0; $i < $count; $i++) { $myVar = 'value' . $i; // set your base variable name $$myVar = $results[$i][$key]; // assign found value to new variable echo 'created variable: ' . '$value' . $i . ' - value : ' . $$myVar . "\n"; } echo $value0 ? $value0 : 'n/a'; echo $value1 ? $value1 : 'n/a'; // etc. /* END NEW */ /** * @param array $arr the multidimensional array we are searching * @param string $key the key we are looking for * @param $results passed by reference - in case the key is found, this array 'stores' the corresponding key-value pair. */ function findKey($arr = [], $key = '', &$results = []) { foreach ($arr as $key0 => $value0) { if ($key0 == $key && !is_array($value0)) { $results[][$key] = $value0; } if (is_array($value0)) { findKey($value0, $key, $results); } } return false; }

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.30.0040.00419.37
8.5.20.0100.00919.44
8.5.10.0100.00519.71
8.5.00.0140.00720.19
8.4.180.0150.00919.85
8.4.170.0110.01123.88
8.4.160.0140.00825.04
8.4.150.0090.00516.81
8.4.140.0120.00917.70
8.4.130.0090.00818.84
8.4.120.0140.00624.16
8.4.110.0120.00918.86
8.4.100.0120.00418.86
8.4.90.0070.00520.55
8.4.80.0110.00820.41
8.4.70.0120.01017.99
8.4.60.0090.01018.95
8.4.50.0130.00718.65
8.4.40.0200.00020.40
8.4.30.0080.00318.64
8.4.20.0120.00319.72
8.4.10.0160.00019.46
8.3.300.0130.00819.07
8.3.290.0110.01020.91
8.3.280.0080.01218.60
8.3.270.0140.00616.53
8.3.260.0120.00716.68
8.3.250.0120.00819.02
8.3.240.0110.00617.05
8.3.230.0040.00516.82
8.3.220.0100.00618.92
8.3.210.0120.00618.41
8.3.200.0040.00516.68
8.3.190.0090.01017.09
8.3.180.0070.00317.32
8.3.170.0180.00020.76
8.3.160.0110.00717.16
8.3.150.0100.01016.79
8.3.140.0070.00016.51
8.3.130.0060.00316.71
8.3.120.0080.00820.81
8.3.110.0030.00616.57
8.3.100.0040.00418.23
8.3.90.0040.00426.77
8.3.80.0100.00316.75
8.3.70.0120.00918.50
8.3.60.0180.00018.43
8.3.50.0070.01023.74
8.3.40.0160.00018.66
8.3.30.0080.00618.86
8.3.20.0050.00320.89
8.3.10.0080.00020.29
8.3.00.0030.00521.73
8.2.300.0120.00820.46
8.2.290.0080.01120.45
8.2.280.0100.00918.70
8.2.270.0140.00716.44
8.2.260.0130.00616.61
8.2.250.0030.00716.52
8.2.240.0030.01316.55
8.2.230.0030.00620.94
8.2.220.0060.01224.06
8.2.210.0060.01326.77
8.2.200.0030.00718.31
8.2.190.0110.00716.58
8.2.180.0070.01125.92
8.2.170.0110.00719.09
8.2.160.0070.00722.96
8.2.150.0040.00425.66
8.2.140.0040.00424.66
8.2.130.0000.00726.16
8.2.120.0080.00026.16
8.2.110.0030.01019.38
8.2.100.0070.00417.91
8.2.90.0040.00418.16
8.2.80.0030.00718.16
8.2.70.0040.00417.63
8.2.60.0030.00617.63
8.2.50.0050.00317.75
8.2.40.0030.00619.50
8.2.30.0080.00019.33
8.2.20.0050.00218.05
8.2.10.0040.00419.38
8.2.00.0000.00719.31
8.1.340.0120.00817.57
8.1.330.0110.00822.07
8.1.320.0070.01118.22
8.1.310.0100.00716.16
8.1.300.0090.00618.16
8.1.290.0060.00330.84
8.1.280.0110.00425.92
8.1.270.0040.00424.66
8.1.260.0070.00026.35
8.1.250.0030.00628.09
8.1.240.0100.00723.88
8.1.230.0090.00320.90
8.1.220.0030.00617.74
8.1.210.0060.00318.77
8.1.200.0000.00817.25
8.1.190.0000.00817.35
8.1.180.0080.00018.10
8.1.170.0000.00717.76
8.1.160.0070.00018.98
8.1.150.0000.00719.01
8.1.140.0040.00422.15
8.1.130.0060.00317.46
8.1.120.0060.00617.51
8.1.110.0000.00717.37
8.1.100.0000.00717.54
8.1.90.0000.00817.38
8.1.80.0000.00817.46
8.1.70.0000.01117.38
8.1.60.0080.00017.57
8.1.50.0070.00017.55
8.1.40.0050.00317.41
8.1.30.0060.00317.73
8.1.20.0040.00417.56
8.1.10.0080.00017.57
8.1.00.0030.00617.41
8.0.300.0000.00719.85
8.0.290.0000.00916.75
8.0.280.0040.00418.46
8.0.270.0050.00216.72
8.0.260.0060.00016.84
8.0.250.0070.00017.00
8.0.240.0030.00316.99
8.0.230.0040.00416.95
8.0.220.0000.00816.93
8.0.210.0000.00616.79
8.0.200.0000.00816.95
8.0.190.0050.00316.99
8.0.180.0080.00016.92
8.0.170.0020.00916.95
8.0.160.0040.00416.94
8.0.150.0000.00716.79
8.0.140.0060.00316.76
8.0.130.0000.00513.32
8.0.120.0030.00616.92
8.0.110.0040.00416.93
8.0.100.0000.00716.86
8.0.90.0040.00416.74
8.0.80.0070.01816.91
8.0.70.0070.00016.97
8.0.60.0070.00016.93
8.0.50.0080.00016.94
8.0.30.0100.01317.00
8.0.20.0150.00316.73
8.0.10.0040.00416.98
8.0.00.0030.01417.07
7.4.330.0050.00015.55
7.4.320.0000.00616.50
7.4.300.0030.00316.61
7.4.290.0040.00416.54
7.4.280.0000.00816.52
7.4.270.0040.00416.67
7.4.260.0000.00613.34
7.4.250.0070.00016.47
7.4.240.0040.00416.65
7.4.230.0030.00316.42
7.4.220.0070.00016.44
7.4.210.0070.01016.56
7.4.200.0000.00716.68
7.4.130.0070.01016.63
7.4.120.0100.01016.68
7.4.110.0120.00616.42
7.4.100.0090.00916.51
7.4.90.0090.00916.46
7.4.80.0030.01519.39
7.4.70.0070.01116.46
7.4.60.0070.01016.46
7.4.50.0030.01216.63
7.4.40.0070.01016.56
7.4.00.0040.01115.02
7.3.330.0040.00416.19
7.3.320.0030.00313.36
7.3.310.0050.00316.38
7.3.300.0030.00316.25
7.3.290.0070.01016.39
7.3.280.0110.00516.28
7.3.260.0160.00316.63
7.3.240.0080.00916.54
7.3.230.0140.00316.65
7.3.210.0110.00416.66
7.3.200.0070.01016.40
7.3.190.0040.01816.48
7.3.180.0090.00916.58
7.3.170.0140.00416.57
7.3.160.0170.00716.47
7.3.120.0030.01014.51
7.3.110.0060.00714.96
7.3.100.0040.01515.07
7.3.90.0110.00614.89
7.3.80.0030.01414.77
7.3.70.0030.01014.63
7.3.60.0080.00514.77
7.3.50.0090.00614.47
7.3.40.0070.00714.67
7.3.30.0060.01014.69
7.3.20.0160.00515.00
7.3.10.0090.00614.92
7.3.00.0080.00814.89
7.2.330.0100.00716.92
7.2.320.0100.01316.76
7.2.310.0080.00816.95
7.2.300.0120.01116.75
7.2.290.0060.00916.72
7.2.250.0120.00315.08
7.2.240.0070.01015.21
7.2.230.0070.00715.12
7.2.220.0120.00315.16
7.2.210.0120.00315.07
7.2.200.0150.00015.31
7.2.190.0100.00314.83
7.2.180.0030.01014.80
7.2.170.0090.00615.03
7.1.330.0070.00713.96
7.1.320.0860.00614.00
7.1.310.0040.01114.09
7.1.300.0040.01113.87
7.1.290.0070.00713.73
7.1.280.0000.01413.98
7.1.270.0050.00813.68
7.1.260.0030.01414.15

preferences:
111.32 ms | 1430 KiB | 5 Q