3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = [ 'children' => [ [ 'id' => 123, 'title' => 'test', 'children' => [ [ 'id' => 345, 'title' => 'test 1', 'children' => [], ], [ 'id' => 567, 'title' => 'test 2', 'children' => [ [ 'id' => 789, 'title' => 'test 3', 'children' => [], ], [ 'id' => 333, 'title' => 'tset 4', 'children' => [ [ 'id' => 222, 'title' => 'test 5', 'children' => [], ], [ 'id' => 111, 'title' => 'test 55', 'children' => [], ], [ 'id' => 444, 'title' => 'test 556', 'children' => [], ], [ 'id' => 666, 'title' => 'test44', 'children' => [], ], ], ], [ 'id' => '5556', 'identifier' => 'test 2', 'children' => [ [ 'id' => 888, 'title' => 'test 2', 'children' => [], ], [ 'id' => 255, 'title' => 'tset', 'children' => [], ], [ 'id' => 454, 'title' => 'warm-up-5837', 'children' => [], ], ], ], ], ], ], ], ], ]; function flattenTree(array $tree): array { $flat = []; foreach ($tree['children'] ?? [] as $child) { $flat[] = ['id' => $child['id'], 'title' => $child['title'] ?? $child['identifier']]; if (!empty($child['children'])) { array_push($flat, ...flattenTree($child, $flat)); } } return $flat; } var_export(flattenTree($array));

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.10.0090.00820.27
8.5.00.0150.01020.04
8.4.150.0030.00014.05
8.4.140.0170.00717.52
8.4.130.0130.00817.73
8.4.120.0230.00620.42
8.4.110.0050.00522.46
8.4.100.0030.00717.79
8.4.90.0040.00522.40
8.4.80.0130.00617.99
8.4.70.0120.00917.93
8.4.60.0140.00818.07
8.4.50.0070.00217.73
8.4.40.0070.01320.54
8.4.30.0030.01618.67
8.4.20.0070.01320.37
8.4.10.0100.01023.75
8.3.280.0130.00720.19
8.3.270.0110.00916.75
8.3.260.0070.00216.64
8.3.250.0050.00718.73
8.3.240.0120.00816.47
8.3.230.0140.00716.60
8.3.220.0130.00717.33
8.3.210.0090.01116.63
8.3.200.0100.01016.81
8.3.190.0150.00516.69
8.3.180.0100.00916.58
8.3.170.0100.00719.13
8.3.160.0060.01318.37
8.3.150.0130.00618.76
8.3.140.0040.00417.29
8.3.130.0060.00318.48
8.3.120.0090.00020.85
8.3.110.0040.00420.94
8.3.100.0050.00516.75
8.3.90.0080.00016.46
8.3.80.0080.00017.97
8.3.70.0160.00616.61
8.3.60.0140.00718.56
8.3.50.0120.00618.61
8.3.40.0070.00720.10
8.3.30.0120.00618.79
8.3.20.0000.00724.18
8.3.10.0040.00424.66
8.3.00.0000.00926.16
8.2.290.0040.00520.77
8.2.280.0110.00716.45
8.2.270.0060.00316.82
8.2.260.0040.00418.27
8.2.250.0060.00317.44
8.2.240.0090.00018.68
8.2.230.0060.00322.58
8.2.220.0080.00024.06
8.2.210.0080.00026.77
8.2.200.0060.00316.50
8.2.190.0130.00616.58
8.2.180.0040.01116.75
8.2.170.0040.01119.09
8.2.160.0100.00322.96
8.2.150.0080.00025.66
8.2.140.0040.00424.66
8.2.130.0080.00026.16
8.2.120.0050.00519.05
8.2.110.0150.00722.00
8.2.100.0040.00917.78
8.2.90.0080.00018.03
8.2.80.0050.00319.07
8.2.70.0030.00617.50
8.2.60.0080.00017.63
8.2.50.0170.00319.52
8.2.40.0080.00819.52
8.2.30.0040.01219.52
8.2.20.0080.00819.52
8.2.10.0080.00819.52
8.2.00.0040.01219.52
8.1.330.0110.00822.25
8.1.320.0100.01016.16
8.1.310.0080.00018.63
8.1.300.0090.00618.45
8.1.290.0040.00418.88
8.1.280.0190.00325.92
8.1.270.0080.00021.96
8.1.260.0040.00426.35
8.1.250.0040.00428.09
8.1.240.0060.00323.97
8.1.230.0070.00422.75
8.1.220.0000.00817.74
8.1.210.0040.00418.77
8.1.200.0000.00817.35
8.1.190.0030.00517.48
8.1.180.0160.00019.52
8.1.170.0130.00519.52
8.1.160.0120.00819.52
8.1.150.0120.00619.52
8.1.140.0090.00919.52
8.1.130.0060.01219.52
8.1.120.0160.00419.52
8.1.110.0190.00019.52
8.1.100.0100.00719.52
8.1.90.0090.00919.52
8.1.80.0130.00419.52
8.1.70.0070.01119.52
8.1.60.0090.00619.52
8.1.50.0120.00419.52
8.1.40.0070.00719.52
8.1.30.0050.01019.52
8.1.20.0160.00019.52
8.1.10.0100.00519.52
8.1.00.0120.00219.52
8.0.300.0070.00019.91
8.0.290.0000.00916.75
8.0.280.0030.00919.52
8.0.270.0050.00919.52
8.0.260.0060.00919.52
8.0.250.0000.01619.52
8.0.240.0130.00019.52
8.0.230.0040.00819.52
8.0.220.0070.00719.52
8.0.210.0130.00319.52
8.0.200.0160.00019.52
8.0.190.0080.00719.52
8.0.180.0120.00419.52
8.0.170.0080.00619.52
8.0.160.0160.00019.52
8.0.150.0110.00519.52
8.0.140.0100.00519.52
8.0.130.0100.00319.52
8.0.120.0110.00519.52
8.0.110.0110.00719.52
8.0.100.0100.00319.52
8.0.90.0100.00319.52
8.0.80.0130.00019.52
8.0.70.0140.00019.52
8.0.60.0040.01119.52
8.0.50.0080.00619.52
8.0.30.0090.00719.52
8.0.20.0110.00319.52
8.0.10.0110.00619.52

preferences:
34.88 ms | 403 KiB | 5 Q