3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr = [ ['one' => 'once', 'two' => ['one' => 'twice', 'two' => 'twice', ['one' => 'thrice']], 'three' => 'once',] ]; $needle = 'one'; // the key we're looking for $result = pathFinder($arr, $needle); /** * function pathFinder() returns the path(s) to a key in an array. * * @param array $arr the subject array * @param string $needle the key we're looking for * * @return array the paths leading to the key we're looking for */ function pathFinder(array $arr = [], $needle = ''): array { static $path = ''; static $paths = []; foreach ($arr as $key => $value) { if (is_array($value)) { $path .= $key . "->"; pathFinder($value, $needle); } else { if ($key === $needle) { $paths[] = $path . $key; // store path } } } return $paths; // return all found paths to key $needle } echo '<pre>'; print_r($result); echo '</pre>';

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.4.120.0100.01022.27
8.4.110.0100.01120.46
8.4.100.0070.01218.84
8.4.90.0100.01020.54
8.4.80.0050.00318.87
8.4.70.0070.00218.85
8.4.60.0140.00618.55
8.4.50.0090.00718.81
8.4.40.0130.00619.48
8.4.30.0030.00620.71
8.4.20.0070.01420.54
8.4.10.0030.00619.48
8.3.250.0110.00719.04
8.3.240.0110.00816.60
8.3.230.0120.00716.61
8.3.220.0110.00919.17
8.3.210.0070.00116.54
8.3.200.0050.00416.83
8.3.190.0070.00217.27
8.3.180.0110.00718.74
8.3.170.0140.00416.37
8.3.160.0090.00917.11
8.3.150.0030.00517.34
8.3.140.0040.00419.08
8.3.130.0070.00416.50
8.3.120.0060.01220.78
8.3.110.0040.00420.94
8.3.100.0110.00724.06
8.3.90.0110.00726.77
8.3.80.0030.00619.36
8.3.70.0120.00316.38
8.3.60.0110.00416.75
8.3.50.0100.00523.73
8.3.40.0070.00718.84
8.3.30.0100.01018.72
8.3.20.0070.00020.66
8.3.10.0050.00323.67
8.3.00.0080.00023.66
8.2.290.0110.00820.65
8.2.280.0080.01018.57
8.2.270.0160.00318.26
8.2.260.0050.00316.47
8.2.250.0030.00518.70
8.2.240.0080.00018.95
8.2.230.0170.00322.58
8.2.220.0030.00637.54
8.2.210.0150.00326.77
8.2.200.0030.00618.88
8.2.190.0070.00718.38
8.2.180.0000.01516.38
8.2.170.0040.01122.96
8.2.160.0000.01422.12
8.2.150.0080.00024.18
8.2.140.0060.00324.66
8.2.130.0040.00426.16
8.2.120.0070.00026.16
8.2.110.0060.00322.24
8.2.100.0000.01117.84
8.2.90.0000.00817.88
8.2.80.0040.00418.91
8.2.70.0060.00317.92
8.2.60.0060.00318.22
8.2.50.0040.00419.32
8.2.40.0040.00419.48
8.2.30.0040.00419.27
8.2.20.0030.00618.21
8.2.10.0040.00419.22
8.2.00.0000.00719.36
8.1.330.0120.00922.07
8.1.320.0110.00717.81
8.1.310.0090.00916.33
8.1.300.0030.00620.34
8.1.290.0030.00630.84
8.1.280.0040.01125.92
8.1.270.0030.00522.18
8.1.260.0040.00426.35
8.1.250.0070.00028.09
8.1.240.0090.00023.80
8.1.230.0060.00617.83
8.1.220.0030.00517.74
8.1.210.0080.00018.77
8.1.200.0100.00017.36
8.1.190.0030.00617.23
8.1.180.0060.00319.04
8.1.170.0050.00318.55
8.1.160.0080.00019.02
8.1.150.0040.00418.93
8.1.140.0020.00522.49
8.1.130.0030.00322.07
8.1.120.0000.00717.36
8.1.110.0070.00017.37
8.1.100.0040.00417.36
8.1.90.0000.00817.48
8.1.80.0040.00417.50
8.1.70.0080.00017.49
8.1.60.0040.00417.48
8.1.50.0040.00417.49
8.1.40.0080.00017.54
8.1.30.0000.00817.57
8.1.20.0040.00417.61
8.1.10.0040.00417.57
8.1.00.0000.00817.55
8.0.300.0040.00418.87
8.0.290.0030.00516.63
8.0.280.0030.00318.43
8.0.270.0040.00416.77
8.0.260.0030.00320.08
8.0.250.0030.00316.93
8.0.240.0040.00416.95
8.0.230.0000.00716.95
8.0.220.0050.00216.82
8.0.210.0070.00016.81
8.0.200.0050.00316.92
8.0.190.0040.00416.89
8.0.180.0000.00816.79
8.0.170.0060.00316.89
8.0.160.0020.00516.78
8.0.150.0030.00316.84
8.0.140.0040.00416.89
8.0.130.0060.00013.36
8.0.120.0030.00616.77
8.0.110.0040.00416.75
8.0.100.0020.00516.91
8.0.90.0000.00816.94
8.0.80.0060.00816.88
8.0.70.0000.00717.00
8.0.60.0000.00716.79
8.0.50.0030.00616.88
8.0.30.0120.00816.94
8.0.20.0190.00616.96
8.0.10.0080.00017.00
8.0.00.0100.00716.96
7.4.330.0050.00016.77
7.4.320.0030.00316.61
7.4.300.0030.00316.53
7.4.290.0040.00416.53
7.4.280.0030.00616.52
7.4.270.0000.00716.50
7.4.260.0040.00416.41
7.4.250.0050.00316.50
7.4.240.0030.00416.53
7.4.230.0000.00716.63
7.4.220.0030.00316.37
7.4.210.0080.00916.53
7.4.200.0030.00316.39
7.4.130.0120.00616.48
7.4.120.0110.01116.66
7.4.110.0130.00416.55
7.4.100.0070.01116.70
7.4.90.0100.00716.55
7.4.80.0060.01519.39
7.4.70.0130.00316.40
7.4.60.0100.00616.45
7.4.50.0030.01016.55
7.4.40.0120.00616.37
7.4.10.0060.01116.36
7.4.00.0120.00316.59
7.3.330.0030.00316.36
7.3.320.0060.00013.35
7.3.310.0030.00316.42
7.3.300.0070.00016.38
7.3.290.0090.00816.36
7.3.260.0160.00616.31
7.3.240.0080.00916.51
7.3.230.0060.01216.41
7.3.210.0090.00916.41
7.3.200.0070.01516.34
7.3.190.0030.01516.59
7.3.180.0050.01116.64
7.3.170.0090.00616.60
7.3.160.0060.01016.44
7.3.130.0040.01216.42
7.3.120.0070.01116.29
7.3.110.0090.00916.15
7.3.100.0080.00616.37
7.3.90.0090.00916.38
7.3.80.0090.00616.47
7.3.70.0080.00816.31
7.3.60.0120.00316.40
7.3.50.0080.00816.36
7.3.40.0110.00516.38
7.3.30.0070.01416.47
7.3.20.0060.01616.23
7.3.10.0060.01016.29
7.3.00.0060.00916.25
7.2.330.0060.01216.50
7.2.320.0130.00316.63
7.2.310.0070.01016.73
7.2.300.0070.01616.53
7.2.290.0030.01316.77
7.2.260.0040.01516.61
7.2.250.0070.01016.70
7.2.240.0150.00016.74
7.2.230.0030.01216.77
7.2.220.0040.01116.73
7.2.210.0100.00716.73
7.2.200.0070.01016.55
7.2.190.0130.01016.66
7.2.180.0100.00616.70
7.2.170.0120.00316.73
7.2.160.0150.00316.64
7.2.150.0060.01316.77
7.2.140.0090.00916.56
7.2.130.0120.00616.64
7.2.120.0090.01516.63
7.2.110.0150.00716.77
7.2.100.0080.00816.62
7.2.90.0090.00916.57
7.2.80.0170.02116.74
7.2.70.0140.00416.82
7.2.60.0090.00616.60
7.2.50.0070.01116.57
7.2.40.0160.00016.78
7.2.30.0100.01416.66
7.2.20.0060.01716.49
7.2.10.0090.00916.80
7.2.00.0210.00316.81

preferences:
27.49 ms | 403 KiB | 5 Q