3v4l.org

run code in 300+ PHP versions simultaneously
<?php $category = [ [ 'sort_id' => 11, 'sort_name' => '一级目录', 'sort_child' => 0 ], [ 'sort_id' => 12, 'sort_name' => '二级目录', 'sort_child' => 11 ], [ 'sort_id' => 13, 'sort_name' => '二级目录', 'sort_child' => 11 ], [ 'sort_id' => 14, 'sort_name' => '三级目录', 'sort_child' => 13 ], [ 'sort_id' => 15, 'sort_name' => '三级目录', 'sort_child' => 13 ], [ 'sort_id' => 16, 'sort_name' => '三级目录', 'sort_child' => 13 ], [ 'sort_id' => 17, 'sort_name' => '一级目录2', 'sort_child' => 0 ], [ 'sort_id' => 18, 'sort_name' => '三级目录', 'sort_child' => 12 ], [ 'sort_id' => 19, 'sort_name' => '三级目录', 'sort_child' => 12 ] ]; $newCategory = []; processCategory($category, 0, $newCategory); $leave = 0; foreach ($newCategory as $currentCategory) { echo $currentCategory['sort_name']; } function processCategory(&$category, $parrentId, &$newCategory) { foreach ($category as $currentCategory) { if ($currentCategory['sort_child'] != $parrentId) continue; array_push($newCategory, $currentCategory); processCategory( $category, $currentCategory['sort_id'], $newCategory ); } }

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.3.60.0110.00416.63
8.3.50.0090.01122.89
8.3.40.0070.00718.97
8.3.30.0080.00619.11
8.3.20.0100.00020.20
8.3.10.0090.00021.76
8.3.00.0040.00419.56
8.2.180.0160.00016.50
8.2.170.0100.00722.96
8.2.160.0090.00620.52
8.2.150.0040.00424.18
8.2.140.0040.00424.66
8.2.130.0040.00426.16
8.2.120.0080.00019.48
8.2.110.0060.00322.02
8.2.100.0090.00317.72
8.2.90.0000.00819.36
8.2.80.0070.00019.40
8.2.70.0030.00617.50
8.2.60.0000.00817.93
8.2.50.0060.00318.07
8.2.40.0000.00818.15
8.2.30.0070.00019.53
8.2.20.0040.00417.82
8.2.10.0040.00418.08
8.2.00.0050.00317.70
8.1.280.0180.00325.92
8.1.270.0060.00322.14
8.1.260.0070.00026.35
8.1.250.0000.00728.09
8.1.240.0060.00319.05
8.1.230.0070.00419.09
8.1.220.0050.00317.79
8.1.210.0000.00818.77
8.1.200.0060.00317.36
8.1.190.0050.00317.53
8.1.180.0030.00518.10
8.1.170.0080.00018.62
8.1.160.0040.00418.86
8.1.150.0000.00718.82
8.1.140.0030.00517.37
8.1.130.0070.00017.84
8.1.120.0020.00517.50
8.1.110.0000.00717.50
8.1.100.0000.00717.52
8.1.90.0040.00417.46
8.1.80.0080.00017.44
8.1.70.0000.00717.39
8.1.60.0000.00817.50
8.1.50.0100.00017.57
8.1.40.0000.00817.54
8.1.30.0030.00517.64
8.1.20.0000.00817.65
8.1.10.0080.00017.62
8.1.00.0040.00417.43
8.0.300.0080.00018.77
8.0.290.0050.00317.30
8.0.280.0000.00718.46
8.0.270.0040.00417.37
8.0.260.0000.00617.13
8.0.250.0000.00716.98
8.0.240.0070.00016.96
8.0.230.0030.00416.98
8.0.220.0050.00216.90
8.0.210.0070.00016.89
8.0.200.0070.00016.96
8.0.190.0080.00016.87
8.0.180.0000.00716.92
8.0.170.0000.00816.88
8.0.160.0030.00316.98
8.0.150.0040.00316.86
8.0.140.0050.00216.82
8.0.130.0030.00313.37
8.0.120.0000.00816.93
8.0.110.0040.00416.83
8.0.100.0000.00716.82
8.0.90.0000.00716.76
8.0.80.0070.01416.94
8.0.70.0030.00516.91
8.0.60.0070.00016.93
8.0.50.0040.00416.81
8.0.30.0100.01017.08
8.0.20.0140.00517.40
8.0.10.0040.00416.84
8.0.00.0110.00616.62
7.4.330.0050.00015.07
7.4.320.0060.00016.52
7.4.300.0060.00016.44
7.4.290.0030.00316.56
7.4.280.0070.00716.52
7.4.270.0000.00716.52
7.4.260.0030.00316.63
7.4.250.0000.00716.56
7.4.240.0070.00116.57
7.4.230.0000.00716.45
7.4.220.0060.01316.52
7.4.210.0050.01116.71
7.4.200.0070.00016.40
7.4.160.0130.00316.72
7.4.150.0110.00717.40
7.4.140.0050.01417.86
7.4.130.0060.01116.62
7.4.120.0050.01316.53
7.4.110.0190.00316.61
7.4.100.0100.01416.71
7.4.90.0070.01016.66
7.4.80.0100.01019.39
7.4.70.0070.01016.50
7.4.60.0090.00916.47
7.4.50.0030.00616.45
7.4.40.0030.01516.50
7.4.30.0100.00716.77
7.4.00.0030.01215.18
7.3.330.0050.00013.35
7.3.320.0020.00213.37
7.3.310.0040.00416.27
7.3.300.0070.00016.25
7.3.290.0070.00916.40
7.3.280.0070.01216.38
7.3.270.0110.00717.40
7.3.260.0090.00916.54
7.3.250.0090.01116.40
7.3.240.0060.01216.35
7.3.230.0100.01316.62
7.3.210.0130.00616.50
7.3.200.0060.00919.39
7.3.190.0100.00716.30
7.3.180.0040.01416.41
7.3.170.0120.00916.44
7.3.160.0120.00416.61
7.2.330.0090.00916.76
7.2.320.0070.01016.83
7.2.310.0110.00816.68
7.2.300.0070.01016.85
7.2.290.0170.00516.54
7.2.110.0040.01116.61
7.2.60.0060.00617.00
7.2.00.0060.00619.48
7.1.200.0000.01215.91
7.1.100.0070.00718.20
7.1.70.0070.00317.10
7.1.60.0100.01419.34
7.1.50.0210.00734.93
7.1.00.0070.07322.48
7.0.200.0030.00516.78
7.0.140.0030.03321.95
7.0.60.0100.07720.09
7.0.50.0030.04017.86
7.0.40.0070.06719.96
7.0.30.0330.07720.13
7.0.20.0230.04720.15
7.0.10.0170.05720.23
7.0.00.0130.05020.08
5.6.210.0070.04320.54
5.6.200.0030.08718.19
5.6.190.0070.05320.50
5.6.180.3730.04320.34
5.6.170.0270.05320.57
5.6.160.0030.05720.50
5.6.150.0100.08018.27
5.6.140.0070.08018.18
5.6.130.0070.08018.18
5.6.120.0030.06021.00
5.6.110.0130.06321.09
5.6.100.0030.06021.14
5.6.90.0130.06720.98
5.6.80.0100.06020.45
5.6.70.4100.04020.39
5.5.350.3270.03020.39
5.5.340.0030.06717.92
5.5.330.0030.04720.20
5.5.320.3470.03720.36
5.5.310.0270.05720.30
5.5.300.0070.06017.98
5.5.290.0000.04317.92
5.5.280.0130.05020.80
5.5.270.0000.09020.77
5.5.260.0030.07720.87
5.5.250.0170.06020.70
5.5.240.0130.05720.27
5.4.450.0230.04019.42
5.4.440.0070.04019.41
5.4.430.0130.05019.29
5.4.420.0100.06019.52
5.4.410.0100.05719.06
5.4.400.0070.08018.86
5.4.390.0230.06318.85
5.4.380.0070.06318.74
5.4.370.0100.07018.80
5.4.360.0100.05318.75
5.4.350.0000.04013.83
5.4.340.0030.05013.79
5.4.320.0030.04014.27
5.4.310.0030.04314.38
5.4.300.0070.03714.29
5.4.290.0030.04014.21
5.4.280.0170.02714.11
5.4.270.0170.03014.17
5.4.260.0030.04714.19
5.4.250.0100.03714.15
5.4.240.0030.04014.16
5.4.230.0030.04014.14
5.4.220.0070.05014.23
5.4.210.0030.03714.09
5.4.200.0030.04014.31
5.4.190.0170.04014.13
5.4.180.0070.03714.18
5.4.170.0100.03314.22
5.4.160.0100.03314.13
5.4.150.0100.03314.14
5.4.140.0100.03713.84
5.4.130.0100.04013.75
5.4.120.0070.03713.80
5.4.110.0070.03313.72
5.4.100.0130.03013.72
5.4.90.0070.03713.77
5.4.80.0030.04014.01
5.4.70.0070.03713.78
5.4.60.0070.03713.83
5.4.50.0100.04314.01
5.4.40.0100.03713.75
5.4.30.0130.03013.76
5.4.20.0070.04013.71
5.4.10.0070.04013.68
5.4.00.0070.03313.39
5.3.290.0100.03714.68
5.3.280.0130.03314.45
5.3.270.0130.03714.54
5.3.260.0070.03714.51
5.3.250.0030.04014.61
5.3.240.0100.03714.66
5.3.230.0030.04014.63
5.3.220.0070.04314.62
5.3.210.0030.05014.48
5.3.200.0170.02714.45
5.3.190.0030.04014.48
5.3.180.0170.03714.48
5.3.170.0030.04014.58
5.3.160.0030.04014.48
5.3.150.0070.03714.49
5.3.140.0030.04014.47
5.3.130.0070.03714.44
5.3.120.0000.04314.41
5.3.110.0030.04714.40
5.3.100.0070.03713.90
5.3.90.0100.05014.02
5.3.80.0070.03714.04
5.3.70.0100.03713.98
5.3.60.0070.04313.93
5.3.50.0070.03713.88
5.3.40.0100.03313.86
5.3.30.0130.03713.80
5.3.20.0070.03713.54
5.3.10.0070.03313.64
5.3.00.0030.04013.58
5.2.170.0030.03311.10
5.2.160.0070.02711.24
5.2.150.0070.03011.04
5.2.140.0070.03011.04
5.2.130.0130.02310.95
5.2.120.0070.02711.08
5.2.110.0000.04010.95
5.2.100.0070.02711.05
5.2.90.0000.03311.01
5.2.80.0030.03310.95
5.2.70.0100.03711.05
5.2.60.0070.03310.92
5.2.50.0070.03011.01
5.2.40.0070.03010.91
5.2.30.0000.03310.97
5.2.20.0070.02710.95
5.2.10.0070.02710.81
5.2.00.0070.02710.84
5.1.60.0000.02710.00
5.1.50.0030.0279.95
5.1.40.0070.0239.96
5.1.30.0000.03010.45
5.1.20.0000.03010.29
5.1.10.0070.02310.14
5.1.00.0100.02010.09
5.0.50.0070.0178.61
5.0.40.0070.0178.43
5.0.30.0070.0308.22
5.0.20.0030.0208.25
5.0.10.0030.0208.20
5.0.00.0030.0308.10
4.4.90.0030.0135.82
4.4.80.0000.0175.79
4.4.70.0000.0175.84
4.4.60.0000.0175.83
4.4.50.0030.0135.83
4.4.40.0000.0305.86
4.4.30.0000.0175.78
4.4.20.0000.0175.87
4.4.10.0030.0135.87
4.4.00.0030.0235.86
4.3.110.0070.0105.82
4.3.100.0030.0135.76
4.3.90.0000.0175.73
4.3.80.0030.0235.87
4.3.70.0070.0105.73
4.3.60.0000.0175.74
4.3.50.0000.0205.76
4.3.40.0000.0275.78
4.3.30.0030.0134.61
4.3.20.0000.0174.48
4.3.10.0000.0174.55
4.3.00.0030.01315.77

preferences:
62.73 ms | 401 KiB | 5 Q