3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr = [ ['comment_id' => 32, 'article_id' => 5, 'parent_id' => 31, 'user_id' => 22, 'content' => 'dolor sit amet consectetur adipisicing', 'created_at' => '02-04-2021'], ['comment_id' => 30, 'article_id' => 5, 'parent_id' => 29, 'user_id' => 22, 'content' => 'Lorem ipsum dolor sit amet.', 'created_at' => '01-04-2021'], ['comment_id' => 31, 'article_id' => 5, 'parent_id' => 29, 'user_id' => 22, 'content' => 'Sit amet consectetur adipisicing', 'created_at' => '02-04-2021'], ['comment_id' => 29, 'article_id' => 5, 'parent_id' => 0, 'user_id' => 22, 'content' => 'dolor sit amet consectetur adipisicing', 'created_at' => '01-04-2021'] ]; $arr_by_comment_id = array_column($arr, null, 'comment_id'); $root_entry = null; foreach ($arr_by_comment_id as &$entry) { if ($entry['parent_id'] === 0) { $root_entry =& $entry; } elseif (array_key_exists($entry['parent_id'], $arr_by_comment_id)) { $arr_by_comment_id[$entry['parent_id']]['comments'][] = $entry; } } unset($entry); // For safety (after reference looping) print_r($root_entry);

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.130.0100.01217.46
8.4.120.0110.00920.44
8.4.110.0070.00319.02
8.4.100.0140.00617.82
8.4.90.0140.00620.44
8.4.80.0140.00818.82
8.4.70.0080.00718.82
8.4.60.0150.00820.70
8.4.50.0050.00417.93
8.4.40.0080.01119.19
8.4.30.0040.01520.24
8.4.20.0070.01418.92
8.4.10.0030.00619.33
8.3.260.0120.00416.30
8.3.250.0100.00818.95
8.3.240.0100.01016.87
8.3.230.0130.00716.61
8.3.220.0030.00420.79
8.3.210.0120.00816.84
8.3.200.0120.00816.52
8.3.190.0070.00717.17
8.3.180.0130.00516.51
8.3.170.0090.01018.90
8.3.160.0140.00716.28
8.3.150.0130.00620.62
8.3.140.0080.00018.59
8.3.130.0060.00316.61
8.3.120.0060.00320.80
8.3.110.0000.00816.50
8.3.100.0060.00316.50
8.3.90.0070.01326.77
8.3.80.0090.00019.36
8.3.70.0180.00018.28
8.3.60.0140.00716.50
8.3.50.0130.00918.32
8.3.40.0120.00318.79
8.3.30.0040.01118.88
8.3.20.0070.00024.18
8.3.10.0040.00424.66
8.3.00.0040.00426.16
8.2.290.0030.00616.95
8.2.280.0050.00320.32
8.2.270.0110.00717.34
8.2.260.0070.00718.94
8.2.250.0080.00016.68
8.2.240.0080.00818.79
8.2.230.0100.00520.94
8.2.220.0050.00324.06
8.2.210.0090.00926.77
8.2.200.0070.00318.88
8.2.190.0150.00618.29
8.2.180.0110.00425.92
8.2.170.0060.00919.11
8.2.160.0140.00422.96
8.2.150.0070.00025.66
8.2.140.0080.00024.66
8.2.130.0070.00026.16
8.2.120.0040.00426.35
8.2.110.0060.00321.18
8.2.100.0040.00817.91
8.2.90.0060.00317.63
8.2.80.0050.00318.59
8.2.70.0040.00417.38
8.2.60.0090.00017.63
8.2.50.0050.00217.93
8.2.40.0000.00818.15
8.2.30.0040.00418.03
8.2.20.0050.00318.10
8.2.10.0070.00019.31
8.2.00.0000.00719.21
8.1.330.0100.01016.04
8.1.320.0160.00317.78
8.1.310.0030.00518.22
8.1.300.0090.00020.24
8.1.290.0000.00930.84
8.1.280.0120.00425.92
8.1.270.0090.00023.77
8.1.260.0080.00028.09
8.1.250.0000.00828.09
8.1.240.0000.00922.19
8.1.230.0120.00020.88
8.1.220.0090.00018.56
8.1.210.0060.00318.77
8.1.200.0060.00317.38
8.1.190.0000.00917.35
8.1.180.0060.00318.10
8.1.170.0080.00017.62
8.1.160.0030.00519.05
8.1.150.0030.00318.89
8.1.140.0040.00418.85
8.1.130.0070.00020.13
8.1.120.0000.00717.39
8.1.110.0000.00817.44
8.1.100.0000.00817.43
8.1.90.0000.00717.34
8.1.80.0070.00017.44
8.1.70.0080.00017.39
8.1.60.0000.00817.54
8.1.50.0030.00517.49
8.1.40.0050.00317.48
8.1.30.0030.00817.64
8.1.20.0040.00417.63
8.1.10.0080.00017.43
8.1.00.0000.00817.40
8.0.300.0040.00418.77
8.0.290.0030.00616.75
8.0.280.0030.00518.50
8.0.270.0000.00817.89
8.0.260.0070.00018.31
8.0.250.0000.00716.96
8.0.240.0060.00016.97
8.0.230.0000.00716.97
8.0.220.0030.00316.94
8.0.210.0000.01116.93
8.0.200.0000.00716.82
8.0.190.0020.00516.86
8.0.180.0040.00416.88
8.0.170.0040.00416.92
8.0.160.0040.00416.93
8.0.150.0030.00516.71
8.0.140.0040.00416.83
8.0.130.0050.00013.40
8.0.120.0000.00916.78
8.0.110.0040.00416.88
8.0.100.0000.00816.93
8.0.90.0040.00416.88
8.0.80.0050.01116.84
8.0.70.0080.00016.70
8.0.60.0000.00816.76
8.0.50.0000.00716.86
8.0.30.0100.00716.80
8.0.20.0040.01617.00
8.0.10.0120.01217.03
8.0.00.0180.00417.00
7.4.330.0050.00015.55
7.4.320.0060.00016.46
7.4.300.0000.00616.63
7.4.290.0000.00816.60
7.4.280.0040.00416.48
7.4.270.0000.00616.51
7.4.260.0060.00013.26
7.4.250.0040.00416.55
7.4.240.0040.00416.57
7.4.230.0000.00716.70
7.4.220.0000.00716.41
7.4.210.0070.00716.57
7.4.200.0040.00416.68
7.4.160.0070.01016.44
7.4.150.0090.01216.54
7.4.140.0070.01016.47
7.4.130.0030.01316.39
7.4.120.0060.00916.53
7.4.110.0000.02016.54
7.4.100.0130.00916.54
7.4.90.0070.01416.42
7.4.80.0160.00716.37
7.4.70.0140.00316.42
7.4.60.0100.01016.56
7.4.50.0060.00916.28
7.4.40.0000.01916.39
7.4.30.0030.01616.43
7.4.20.0110.01116.52
7.4.10.0190.00316.63
7.4.00.0030.01516.36
7.3.330.0070.00016.39
7.3.320.0000.00513.25
7.3.310.0000.00716.18
7.3.300.0060.00016.25
7.3.290.0100.00716.35
7.3.270.0080.00816.29
7.3.260.0030.01316.30
7.3.250.0030.01316.33
7.3.240.0180.00016.34
7.3.230.0090.00916.26
7.3.220.0030.01716.26
7.3.210.0060.01116.20
7.3.200.0070.01016.29
7.3.190.0000.02016.26
7.3.180.0100.01016.27
7.3.170.0110.00816.21
7.3.160.0110.00816.33
7.3.150.0060.01616.21
7.3.140.0040.01716.32
7.3.130.0130.00716.32
7.3.120.0060.01316.37
7.3.110.0140.00616.18
7.3.100.0090.00916.24
7.3.90.0150.00616.50
7.3.80.0100.00716.25
7.3.70.0090.00716.31
7.3.60.0090.00616.38
7.3.50.0110.01116.42
7.3.40.0060.01616.49
7.3.30.0150.00516.38
7.3.20.0130.01016.39
7.3.10.0070.01016.34
7.3.00.0350.00516.33

preferences:
38.62 ms | 403 KiB | 5 Q