3v4l.org

run code in 500+ PHP versions simultaneously
<?php $array = array ( 0 => array ( 'id' => '1', 'p_pag' => '0', 'link' => 'Contact', 'children' => array ( 0 => array ( 'id' => '2', 'p_pag' => '1', 'link' => 'Contact-County', 'children' => array ( 0 => array ( 'id' => '3', 'p_pag' => '2', 'link' => 'Contact-Town-1', 'children' => array ( ), ), ), ), ), ), ); function getLinkPathById(array $array, string $toId): ?string { foreach ($array as $row) { if ( $row['id'] === $toId || ($deeper = getLinkPathById($row['children'], $toId)) ) { return '/' . $row['link'] . ($deeper ?? null); } } return null; } echo "1: " . getLinkPathById($array, 1) . PHP_EOL; echo "2: " . getLinkPathById($array, 2) . PHP_EOL; echo "3: " . getLinkPathById($array, 3) . PHP_EOL; echo "4: " . getLinkPathById($array, 4);

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.60.0100.00616.90
8.5.50.0120.00616.64
8.5.30.0090.00821.32
8.5.20.0120.00719.63
8.5.10.0100.00720.24
8.5.00.0130.00919.99
8.4.210.0050.00521.39
8.4.180.0160.00619.73
8.4.170.0150.00824.04
8.4.160.0130.00823.91
8.4.150.0060.00616.86
8.4.140.0150.00517.33
8.4.130.0120.00917.48
8.4.120.0130.00720.72
8.4.110.0140.00722.46
8.4.100.0120.00517.95
8.4.90.0150.00618.84
8.4.80.0130.00817.91
8.4.70.0100.01019.62
8.4.60.0160.00519.34
8.4.50.0100.00918.63
8.4.40.0090.00619.45
8.4.30.0060.00318.69
8.4.20.0000.00917.57
8.4.10.0100.01023.93
8.3.300.0100.01020.69
8.3.290.0080.01518.38
8.3.280.0130.00718.31
8.3.270.0080.01316.80
8.3.260.0110.00916.48
8.3.250.0070.00419.23
8.3.240.0140.00616.69
8.3.230.0100.00916.63
8.3.220.0040.01017.13
8.3.210.0040.00316.51
8.3.200.0100.00918.96
8.3.190.0100.00817.16
8.3.180.0110.00717.34
8.3.170.0090.00921.03
8.3.160.0100.01016.73
8.3.150.0110.00716.99
8.3.140.0080.00016.53
8.3.130.0060.00316.77
8.3.120.0120.00418.77
8.3.110.0090.00916.50
8.3.100.0030.00624.06
8.3.90.0050.00226.77
8.3.80.0030.01016.74
8.3.70.0100.01016.75
8.3.60.0040.01216.75
8.3.50.0140.00720.13
8.3.40.0130.00722.03
8.3.30.0060.00918.58
8.3.20.0040.00424.18
8.3.10.0030.00624.66
8.3.00.0080.00026.16
8.2.300.0080.01218.11
8.2.290.0050.00420.46
8.2.280.0110.00416.92
8.2.270.0110.01117.27
8.2.260.0110.00720.73
8.2.250.0050.00316.63
8.2.240.0090.00018.88
8.2.230.0090.00020.94
8.2.220.0080.00037.54
8.2.210.0030.01626.77
8.2.200.0050.00516.50
8.2.190.0060.01318.29
8.2.180.0070.01125.92
8.2.170.0120.00418.70
8.2.160.0060.01022.96
8.2.150.0040.00425.66
8.2.140.0040.00424.66
8.2.130.0040.00426.16
8.2.120.0070.00026.16
8.2.110.0040.00422.21
8.2.100.0030.01017.59
8.2.90.0000.00818.27
8.2.80.0050.00318.73
8.2.70.0060.00317.36
8.2.60.0030.00617.93
8.2.50.0060.00318.07
8.2.40.0040.00418.22
8.2.30.0030.00618.00
8.2.20.0050.00219.31
8.2.10.0070.00018.18
8.2.00.0040.00419.18
8.1.340.0090.01119.89
8.1.330.0090.00722.13
8.1.320.0060.01416.12
8.1.310.0040.01516.11
8.1.300.0150.00418.33
8.1.290.0000.01118.88
8.1.280.0130.00725.92
8.1.270.0080.00024.66
8.1.260.0000.00726.35
8.1.250.0080.00028.09
8.1.240.0060.00323.96
8.1.230.0000.01119.09
8.1.220.0060.00317.79
8.1.210.0000.00818.77
8.1.200.0100.00017.36
8.1.190.0080.00017.10
8.1.180.0040.00418.10
8.1.170.0040.00418.57
8.1.160.0040.00418.99
8.1.150.0040.00418.62
8.1.140.0040.00417.49
8.1.130.0080.00020.36
8.1.120.0000.00817.45
8.1.110.0030.01017.44
8.1.100.0060.00617.43
8.1.90.0080.00317.40
8.1.80.0130.00217.33
8.1.70.0100.00017.46
8.1.60.0110.00417.59
8.1.50.0060.01217.38
8.1.40.0140.00517.57
8.1.30.0120.00617.64
8.1.20.0110.00717.51
8.1.10.0070.00717.53
8.1.00.0060.00617.43
8.0.300.0000.00718.77
8.0.290.0000.00816.75
8.0.280.0030.00318.44
8.0.270.0040.00417.27
8.0.260.0040.00418.38
8.0.250.0030.00617.03
8.0.240.0100.00016.90
8.0.230.0050.00516.48
8.0.220.0100.00016.79
8.0.210.0090.00316.72
8.0.200.0110.00016.63
8.0.190.0060.00616.81
8.0.180.0080.00816.96
8.0.170.0050.00916.84
8.0.160.0110.00416.81
8.0.150.0130.00016.90
8.0.140.0150.00016.86
8.0.130.0100.00516.80
8.0.120.0110.00516.92
8.0.110.0030.01116.96
8.0.100.0060.00816.99
8.0.90.0060.00616.57
8.0.80.0040.00816.63
8.0.70.0090.00616.91
8.0.60.0080.00416.97
8.0.50.0040.00716.71
8.0.30.0130.00016.92
8.0.20.0140.00016.80
8.0.10.0110.00416.98
7.4.330.0000.00615.55
7.4.320.0110.00516.45
7.4.300.0090.00016.55
7.4.290.0110.00016.46
7.4.280.0040.00716.58
7.4.270.0080.00316.25
7.4.260.0030.00616.59
7.4.250.0040.00716.22
7.4.240.0030.00816.37
7.4.230.0040.00816.41
7.4.220.0080.00716.60
7.4.210.0120.00216.60
7.4.200.0150.00016.47
7.4.190.0100.00516.63
7.4.180.0120.00416.51
7.4.160.0100.00016.67
7.4.150.0080.00316.51
7.4.140.0050.00515.81
7.4.130.0110.00016.17
7.4.120.0070.00415.93
7.4.110.0050.00515.90
7.4.100.0040.01116.50
7.4.90.0000.01016.02
7.4.80.0100.00316.42
7.4.70.0110.00416.44
7.4.60.0150.00016.45
7.4.50.0110.00316.39
7.4.40.0110.00416.36
7.4.30.0100.00516.41
7.4.20.0110.00416.52
7.4.10.0100.00316.45
7.4.00.0140.00016.34

preferences:
73.48 ms | 1258 KiB | 5 Q