3v4l.org

run code in 300+ PHP versions simultaneously
<?php declare(strict_types=1); $items = [ (object)['id' => 0, 'name' => "root"], (object)['id' => 1, 'parentId' => 0, 'name' => "foo"], (object)['id' => 2, 'parentId' => 1, 'name' => "bar"], (object)['id' => 3, 'parentId' => 1, 'name' => "qux"], (object)['id' => 4, 'parentId' => 3, 'name' => "zip"], (object)['id' => 5, 'parentId' => 4, 'name' => "baz"] ]; $itemsById = []; foreach ($items as $item) { $itemsById[$item->id] = $item; } // --- foreach ($itemsById as $id => $item) { if (isset($item->parentId)) { $itemsById[$item->parentId]->children[] = $item; } } $root = $itemsById[0]; var_dump($root);

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.0120.00717.47
8.5.20.0140.00520.14
8.5.10.0070.01120.15
8.5.00.0110.01020.29
8.4.180.0070.00521.57
8.4.170.0140.00723.86
8.4.160.0120.01023.75
8.4.150.0070.00516.88
8.4.140.0090.01217.42
8.4.130.0080.00417.78
8.4.120.0130.00720.66
8.4.110.0120.00918.82
8.4.100.0090.00917.66
8.4.90.0060.00318.00
8.4.80.0140.00617.80
8.4.70.0040.00617.98
8.4.60.0140.00817.68
8.4.50.0070.00617.80
8.4.40.0100.01018.92
8.4.30.0130.00317.55
8.4.20.0070.01117.82
8.4.10.0040.00717.46
8.3.300.0130.00820.83
8.3.290.0120.01020.90
8.3.280.0110.00918.68
8.3.270.0100.00916.80
8.3.260.0070.00216.84
8.3.250.0120.00818.89
8.3.240.0060.00216.68
8.3.230.0120.00716.83
8.3.220.0100.00317.14
8.3.210.0130.00516.94
8.3.200.0100.01018.98
8.3.190.0080.00816.76
8.3.180.0100.01018.40
8.3.170.0000.00916.50
8.3.160.0140.00416.87
8.3.150.0030.01717.08
8.3.140.0060.00316.72
8.3.130.0050.00318.50
8.3.120.0000.00819.11
8.3.110.0090.00020.94
8.3.100.0080.00424.06
8.3.90.0050.00326.77
8.3.80.0030.00717.97
8.3.70.0120.00318.36
8.3.60.0110.00416.47
8.3.50.0190.01221.95
8.3.40.0040.01119.02
8.3.30.0060.00918.85
8.3.20.0000.00820.15
8.3.10.0030.00523.64
8.3.00.0040.00419.91
8.2.300.0140.00818.85
8.2.290.0130.00620.29
8.2.280.0130.00616.84
8.2.270.0070.01118.18
8.2.260.0050.00319.06
8.2.250.0070.01118.28
8.2.240.0090.00017.21
8.2.230.0070.00322.58
8.2.220.0130.00737.54
8.2.210.0040.00426.77
8.2.200.0030.00616.75
8.2.190.0070.01118.59
8.2.180.0110.00416.75
8.2.170.0120.00422.96
8.2.160.0070.00720.45
8.2.150.0030.00524.18
8.2.140.0070.00024.66
8.2.130.0030.00619.27
8.2.120.0110.00726.35
8.2.110.0030.00620.43
8.2.100.0100.00317.84
8.2.90.0030.00617.75
8.2.80.0040.00417.97
8.2.70.0000.00917.93
8.2.60.0090.00017.93
8.2.50.0040.00418.10
8.2.40.0070.00020.47
8.2.30.0040.00420.64
8.2.20.0070.00017.86
8.2.10.0040.00418.04
8.2.00.0000.00818.00
8.1.340.0110.00921.70
8.1.330.0110.00816.85
8.1.320.0090.01116.37
8.1.310.0040.00417.01
8.1.300.0110.00818.45
8.1.290.0090.00030.84
8.1.280.0140.00325.92
8.1.270.0060.00320.38
8.1.260.0040.00428.09
8.1.250.0080.00028.09
8.1.240.0060.00323.87
8.1.230.0080.00419.16
8.1.220.0000.00917.74
8.1.210.0060.00318.77
8.1.200.0030.00617.35
8.1.190.0030.00617.25
8.1.180.0040.00418.10
8.1.170.0000.01018.59
8.1.160.0060.00320.74
8.1.150.0050.00318.82
8.1.140.0030.00519.65
8.1.130.0050.00217.71
8.1.120.0040.00417.45
8.1.110.0030.00617.47
8.1.100.0000.00817.49
8.1.90.0040.00417.37
8.1.80.0000.00717.34
8.1.70.0080.00017.29
8.1.60.0040.00417.50
8.1.50.0000.00817.52
8.1.40.0030.00517.54
8.1.30.0040.00417.57
8.1.20.0000.00817.59
8.1.10.0040.00417.60
8.1.00.0050.00317.41
8.0.300.0030.00621.59
8.0.290.0000.00816.75
8.0.280.0000.00718.45
8.0.270.0040.00417.13
8.0.260.0000.00717.19
8.0.250.0040.00416.96
8.0.240.0040.00416.92
8.0.230.0040.00416.98
8.0.220.0040.00416.82
8.0.210.0000.00716.98
8.0.200.0030.00616.89
8.0.190.0000.00817.02
8.0.180.0000.00716.93
8.0.170.0040.00417.02
8.0.160.0050.00517.02
8.0.150.0040.00316.79
8.0.140.0040.00416.92
8.0.130.0060.00013.39
8.0.120.0040.00416.99
8.0.110.0070.00016.87
8.0.100.0000.00716.97
8.0.90.0030.00616.95
8.0.80.0150.00616.85
8.0.70.0000.00816.79
8.0.60.0080.00016.82
8.0.50.0080.00016.99
8.0.30.0120.00917.24
8.0.20.0090.01117.40
8.0.10.0040.00416.91
8.0.00.0170.00216.91
7.4.330.0020.00216.76
7.4.320.0040.00416.61
7.4.300.0060.00016.54
7.4.290.0030.00316.51
7.4.280.0090.00016.41
7.4.270.0050.00216.57
7.4.260.0000.00716.49
7.4.250.0040.00416.34
7.4.240.0000.00716.54
7.4.230.0000.00716.42
7.4.220.0120.01316.50
7.4.210.0100.00916.54
7.4.200.0070.00016.69
7.4.160.0110.00616.48
7.4.150.0070.01017.40
7.4.140.0170.00617.86
7.4.130.0120.00916.49
7.4.120.0100.01216.61
7.4.110.0110.00816.59
7.4.100.0090.00916.63
7.4.90.0100.01016.32
7.4.80.0070.01119.39
7.4.70.0080.00916.41
7.4.60.0100.00616.57
7.4.50.0040.01516.51
7.4.40.0100.01316.45
7.4.30.0110.00716.29
7.4.10.0070.01014.91
7.4.00.0050.01014.99
7.3.330.0030.00313.38
7.3.320.0050.00013.38
7.3.310.0030.00316.48
7.3.300.0030.00316.29
7.3.290.0070.00716.36
7.3.280.0150.00516.40
7.3.270.0100.01417.40
7.3.260.0120.00616.36
7.3.250.0100.00916.55
7.3.240.0120.00916.41
7.3.230.0090.01216.39
7.3.210.0160.00516.51
7.3.200.0040.01516.63
7.3.190.0040.01416.62
7.3.180.0120.01216.31
7.3.170.0100.00716.30
7.3.160.0070.01016.39
7.3.130.0100.00714.66
7.3.120.0030.01315.04
7.3.110.0070.01115.06
7.3.100.0090.00614.84
7.3.90.0030.01714.61
7.3.80.0090.00315.20
7.3.70.0030.00715.02
7.3.60.0030.01314.53
7.3.50.0030.01614.88
7.3.40.0100.00314.92
7.3.30.0080.00814.66
7.3.20.0030.00616.61
7.3.10.0080.00416.47
7.3.00.0090.00916.66
7.2.330.0090.00916.50
7.2.320.0140.00616.75
7.2.310.0190.00716.52
7.2.300.0100.00916.63
7.2.290.0130.00716.70
7.2.260.0000.01815.17
7.2.250.0100.00714.83
7.2.240.0110.00415.04
7.2.230.0160.00314.96
7.2.220.0030.01415.31
7.2.210.0100.00314.84
7.2.200.0100.00414.96
7.2.190.0060.00614.99
7.2.180.0060.00914.96
7.2.170.0070.00715.13
7.2.160.0110.00415.05
7.2.150.0030.01016.88
7.2.140.0030.01016.77
7.2.130.0040.01217.02
7.2.120.0030.01016.84
7.2.110.0070.00716.85
7.2.100.0080.00616.80
7.2.90.0040.00716.93
7.2.80.0000.01217.03
7.2.70.0040.01116.85
7.2.60.0030.00916.83
7.2.50.0030.01016.77
7.2.40.0000.01217.14
7.2.30.0070.00416.94
7.2.20.0090.00617.06
7.2.10.0060.00616.79
7.2.00.0120.00718.15
7.1.330.0140.00315.74
7.1.320.0030.01415.90
7.1.310.0000.01415.93
7.1.300.0100.00715.89
7.1.290.0100.00715.64
7.1.280.0000.00815.71
7.1.270.0070.01115.91
7.1.260.0030.01015.77
7.1.250.0040.01115.79
7.1.240.0070.00715.75
7.1.230.0120.00315.76
7.1.220.0070.00715.75
7.1.210.0000.01415.63
7.1.200.0060.00615.95
7.1.190.0100.00315.83
7.1.180.0040.00815.93
7.1.170.0030.00915.84
7.1.160.0040.00815.96
7.1.150.0070.00315.95
7.1.140.0100.00315.75
7.1.130.0030.00915.93
7.1.120.0000.01115.93
7.1.110.0040.01115.99
7.1.100.0050.00817.03
7.1.90.0070.01015.79
7.1.80.0070.00715.95
7.1.70.0030.00816.31
7.1.60.0100.00817.63
7.1.50.0020.01316.51
7.1.40.0040.01116.02
7.1.30.0090.00615.96
7.1.20.0130.00315.58
7.1.10.0040.01515.83
7.1.00.0070.04019.15
7.0.330.0000.01215.42
7.0.320.0120.00315.63
7.0.310.0070.00715.15
7.0.300.0060.00615.53
7.0.290.0120.00015.43
7.0.280.0060.00615.27
7.0.270.0030.00915.52
7.0.260.0000.01115.41
7.0.250.0060.01015.55
7.0.240.0070.00315.27
7.0.230.0030.00615.28
7.0.220.0120.00315.33
7.0.210.0000.00915.66
7.0.200.0080.00416.04
7.0.190.0070.00715.46
7.0.180.0100.00315.49
7.0.170.0000.01315.44
7.0.160.0000.01015.45
7.0.150.0030.01415.43
7.0.140.0070.00715.60
7.0.130.0030.01015.60
7.0.120.0000.00915.48
7.0.110.0030.00615.29
7.0.100.0000.01515.55
7.0.90.0060.01015.58
7.0.80.0030.00615.37
7.0.70.0030.00615.58
7.0.60.0050.02517.70
7.0.50.0070.03516.69
7.0.40.0110.01916.79
7.0.30.0200.02516.84
7.0.20.0180.03616.86
7.0.10.0050.04816.62
7.0.00.0110.03416.80
5.6.400.0060.00614.66
5.6.390.0030.00714.15
5.6.380.0080.00614.54
5.6.370.0090.00614.80
5.6.360.0000.00914.12
5.6.350.0070.00714.33
5.6.340.0060.00614.28
5.6.330.0030.01014.28
5.6.320.0030.01014.83
5.6.310.0070.00714.73
5.6.300.0000.01814.69
5.6.290.0030.01314.81
5.6.280.0070.02217.62
5.6.270.0000.00814.77
5.6.260.0090.00614.43
5.6.250.0040.00714.76
5.6.240.0100.00314.76
5.6.230.0030.00914.37
5.6.220.0070.00714.46
5.6.210.0100.04217.55
5.6.200.0080.02816.36
5.6.190.0050.04317.54
5.6.180.0120.03017.46
5.6.170.0150.03417.49
5.6.160.0080.04217.45
5.6.150.0060.03916.39
5.6.140.0070.03416.31
5.6.130.0020.04916.24
5.6.120.0070.04517.65
5.6.110.0040.05417.92
5.6.100.0080.04517.74
5.6.90.0090.02017.84
5.6.80.0070.04417.26
5.6.70.0030.01014.30
5.6.60.0040.01114.14
5.6.50.0070.00314.44
5.6.40.0080.00414.18
5.6.30.0000.01714.66
5.6.20.0060.00914.24
5.6.10.0060.00714.12
5.6.00.0030.00714.45
5.5.380.0000.01214.39
5.5.370.0000.00914.51
5.5.360.0120.00614.71
5.5.350.0120.03817.38
5.5.340.0080.03316.02
5.5.330.0030.02517.37
5.5.320.0250.02817.27
5.5.310.0140.04217.49
5.5.300.0050.02616.31
5.5.290.0050.04816.22
5.5.280.0100.04317.73
5.5.270.0140.04017.44
5.5.260.0070.03617.56
5.5.250.0070.04117.44
5.5.240.0150.03917.18
5.5.230.0100.00314.09
5.5.220.0070.00414.18
5.5.210.0060.00314.58
5.5.200.0030.01314.36
5.5.190.0110.00414.47
5.5.180.0070.00714.32
5.5.170.0070.00614.22
5.5.160.0090.00614.43
5.5.150.0090.00614.31
5.5.140.0040.01114.46
5.5.130.0040.01114.35
5.5.120.0090.00613.92
5.5.110.0100.00714.11
5.5.100.0000.01414.58
5.5.90.0000.00914.57
5.5.80.0040.01014.38
5.5.70.0030.01014.40
5.5.60.0060.00614.23
5.5.50.0030.01214.38
5.5.40.0090.00014.26
5.5.30.0040.00714.59
5.5.20.0100.00014.18
5.5.10.0080.00814.37
5.5.00.0070.00714.48

preferences:
54.21 ms | 2668 KiB | 5 Q