3v4l.org

run code in 500+ PHP versions simultaneously
<?php $menu = [ 'root' => [ 'items' => [ 'A' => [ 'p' => [1, 2, 9], ], 'B' => [ 'p' => [1, 2, 3, 9], ], 'C' => [ 'p' => [1, 2, 4, 9], ], 'D' => [ 'items' => [ 'D1' => [ 'p' => [1, 2, 3, 4, 9], ], 'D2' => [ 'p' => [1, 2, 3, 4], ], ], ], 'E' => [ 'items' => [ 'E1' => [ 'p' => [1, 2, 10], ], ], ], 'F' => [ 'items' => [ 'F1' => [ 'p' => [5, 6], ], 'F2' => [ 'p' => [7, 8], ], ], ], ], ], ]; function recursive_ps($elem) { $output = []; if (isset($elem['items'])) { foreach($elem['items'] as $key => $value) { if (isset($value['p'])) { $output = array_merge($output, $value['p']); } if (isset($value['items'])) { // merge the return value of function $output = array_merge($output, recursive_ps($value)); } } } return $output; } $output = array_values(array_unique(recursive_ps($menu['root']))); print_r($output);

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.90.0120.00716.73
8.5.80.0100.01016.80
8.5.70.0100.00716.80
8.5.60.0130.00416.98
8.5.50.0040.00416.68
8.5.30.0140.00519.47
8.5.20.0020.00519.61
8.5.10.0110.00716.64
8.5.00.0150.00719.95
8.4.230.0140.00819.61
8.4.220.0080.01019.49
8.4.210.0110.01221.40
8.4.180.0130.01019.63
8.4.170.0120.01023.78
8.4.160.0070.01423.76
8.4.150.0080.00516.84
8.4.140.0110.01117.48
8.4.130.0060.01117.64
8.4.120.0040.00424.30
8.4.110.0130.00718.81
8.4.100.0080.01218.83
8.4.90.0040.00420.56
8.4.80.0130.00817.66
8.4.70.0140.00617.84
8.4.60.0040.00418.80
8.4.50.0110.01119.47
8.4.40.0100.01019.39
8.4.30.0040.01120.41
8.4.20.0060.00918.62
8.4.10.0040.00419.52
8.3.320.0120.00818.64
8.3.310.0120.00718.54
8.3.300.0110.00919.25
8.3.290.0110.01118.49
8.3.280.0070.00516.34
8.3.270.0140.01116.66
8.3.260.0100.00816.76
8.3.250.0090.00916.57
8.3.240.0050.00317.11
8.3.230.0150.00616.77
8.3.220.0080.01018.85
8.3.210.0090.00916.70
8.3.200.0100.01016.55
8.3.190.0090.00917.05
8.3.180.0100.00818.36
8.3.170.0040.00418.92
8.3.160.0140.00718.46
8.3.150.0160.00318.99
8.3.140.0160.00318.24
8.3.130.0000.00818.48
8.3.120.0080.00420.75
8.3.110.0000.00820.94
8.3.100.0040.00418.30
8.3.90.0090.00626.77
8.3.80.0050.00519.36
8.3.70.0120.00916.75
8.3.60.0150.00616.73
8.3.50.0070.00718.31
8.3.40.0190.00418.76
8.3.30.0110.00418.50
8.3.20.0040.00424.18
8.3.10.0040.00424.66
8.3.00.0040.00426.16
8.2.320.0090.00818.12
8.2.310.0110.00918.16
8.2.300.0110.01218.13
8.2.290.0110.00720.61
8.2.280.0080.00320.03
8.2.270.0090.00917.18
8.2.260.0070.01119.15
8.2.250.0070.00018.39
8.2.240.0160.00317.19
8.2.230.0160.00322.58
8.2.220.0070.00324.06
8.2.210.0130.00726.77
8.2.200.0030.00618.88
8.2.190.0130.00918.16
8.2.180.0170.00325.92
8.2.170.0120.00318.93
8.2.160.0100.00322.96
8.2.150.0190.00025.66
8.2.140.0020.00524.66
8.2.130.0090.00626.16
8.2.120.0040.00426.35
8.2.110.0070.00320.31
8.2.100.0110.00417.84
8.2.90.0050.00317.88
8.2.80.0050.00318.78
8.2.70.0080.00017.50
8.2.60.0030.00618.04
8.2.50.0050.00318.07
8.2.40.0050.00319.88
8.2.30.0000.00718.19
8.2.20.0000.00718.02
8.2.10.0030.00521.11
8.2.00.0040.00419.20
8.1.340.0130.00721.57
8.1.330.0120.00821.86
8.1.320.0150.00316.13
8.1.310.0080.00016.86
8.1.300.0090.00917.95
8.1.290.0030.00630.84
8.1.280.0110.01125.92
8.1.270.0040.00423.99
8.1.260.0100.00728.09
8.1.250.0110.00728.09
8.1.240.0060.00318.86
8.1.230.0090.00317.89
8.1.220.0000.00817.76
8.1.210.0000.00818.77
8.1.200.0060.00317.35
8.1.190.0000.00917.13
8.1.180.0080.00018.10
8.1.170.0000.00818.63
8.1.160.0000.00819.02
8.1.150.0050.00318.88
8.1.140.0040.00418.94
8.1.130.0000.00717.40
8.1.120.0070.00017.37
8.1.110.0050.00317.50
8.1.100.0000.00717.41
8.1.90.0000.00717.47
8.1.80.0000.00817.49
8.1.70.0000.00817.39
8.1.60.0040.00417.64
8.1.50.0050.00317.58
8.1.40.0030.00517.40
8.1.30.0030.00617.53
8.1.20.0040.00417.60
8.1.10.0040.00417.56
8.1.00.0040.00417.35
8.0.300.0000.00718.77
8.0.290.0080.00016.75
8.0.280.0030.00618.46
8.0.270.0030.00318.07
8.0.260.0000.00716.83
8.0.250.0030.00317.00
8.0.240.0000.00716.85
8.0.230.0030.00316.91
8.0.220.0000.00716.82
8.0.210.0070.00016.93
8.0.200.0070.00016.98
8.0.190.0080.00016.94
8.0.180.0030.00516.84
8.0.170.0000.00916.82
8.0.160.0040.00416.92
8.0.150.0000.00716.84
8.0.140.0030.00616.71
8.0.130.0050.00013.39
8.0.120.0060.00316.90
8.0.110.0070.00016.90
8.0.100.0000.00716.71
8.0.90.0040.00416.95
8.0.80.0100.00516.89
8.0.70.0040.00416.75
8.0.60.0000.00716.90
8.0.50.0070.00016.90
8.0.30.0070.01016.84
8.0.20.0000.01716.94
8.0.10.0030.01317.05
8.0.00.0100.00617.06
7.4.330.0050.00015.55
7.4.320.0030.00316.54
7.4.300.0000.00816.55
7.4.290.0000.00716.44
7.4.280.0050.00216.37
7.4.270.0000.00716.71
7.4.260.0050.00013.29
7.4.250.0030.00316.61
7.4.240.0030.00316.60
7.4.230.0030.00316.42
7.4.220.0040.00416.44
7.4.210.0090.01116.57
7.4.200.0050.00316.69
7.4.160.0080.01216.63
7.4.150.0060.01516.50
7.4.140.0110.00416.50
7.4.130.0120.00916.41
7.4.120.0070.01416.43
7.4.110.0100.00716.38
7.4.100.0060.01216.37
7.4.90.0070.01016.45
7.4.80.0140.00316.50
7.4.70.0060.01516.50
7.4.60.0080.01216.65
7.4.50.0070.00716.36
7.4.40.0210.00016.38
7.4.30.0030.01316.45
7.4.20.0070.01316.40
7.4.10.0100.00616.43
7.4.00.0030.01216.39
7.3.330.0000.00716.25
7.3.320.0000.00613.23
7.3.310.0030.00316.19
7.3.300.0070.00016.41
7.3.290.0080.00816.33
7.3.270.0060.00916.29
7.3.260.0000.01416.28
7.3.250.0030.01716.30
7.3.240.0030.01216.28
7.3.230.0120.00616.29
7.3.220.0080.00916.32
7.3.210.0110.00416.31
7.3.200.0080.01116.25
7.3.190.0060.00916.22
7.3.180.0140.00716.25
7.3.170.0130.00716.29
7.3.160.0040.01116.16
7.3.150.0030.01216.20
7.3.140.0120.00316.15
7.3.130.0070.01316.25
7.3.120.0090.00616.38
7.3.110.0080.00816.26
7.3.100.0130.00716.23
7.3.90.0070.01416.51
7.3.80.0030.01416.25
7.3.70.0130.00816.33
7.3.60.0130.00616.39
7.3.50.0060.01016.43
7.3.40.0090.00616.35
7.3.30.0060.01016.39
7.3.20.0070.01516.44
7.3.10.0100.00716.34
7.3.00.0630.01216.32

preferences:
40.04 ms | 1442 KiB | 5 Q