3v4l.org

run code in 300+ PHP versions simultaneously
<?php // result from query: SELECT * FROM depts $depts = array( array( // row #0 'deptid' => 1, 'dept_code' => '1', 'dept_name' => 'wadir Umum', 'parent_deptid' => 0, ), array( // row #1 'deptid' => 2, 'dept_code' => '101', 'dept_name' => 'bagian umum', 'parent_deptid' => 1, ), array( // row #2 'deptid' => 3, 'dept_code' => '10101', 'dept_name' => 'kepala umum', 'parent_deptid' => 2, ), array( // row #3 'deptid' => 4, 'dept_code' => '102', 'dept_name' => 'bagian privasi', 'parent_deptid' => 1, ), array( // row #4 'deptid' => 5, 'dept_code' => '1010101', 'dept_name' => 'SUb bagian Tu', 'parent_deptid' => 3, ), array( // row #5 'deptid' => 6, 'dept_code' => '1010102', 'dept_name' => 'bagian umum', 'parent_deptid' => 3, ), ); $nodes = array(); $roots = array(); // init nodes foreach ($depts as $dept) { $dept['childs'] = array(); // init childs $nodes[$dept['deptid']] = $dept; } foreach ($depts as $dept) { if ($dept['parent_deptid'] == 0) { $roots[] = $dept['deptid']; // add root } else { $nodes[$dept['parent_deptid']]['childs'][] = $dept['deptid']; // add to parents chlids list } } function getSubtreeHTMLList($deptsids, $nodes) { $result = '<ul>'; foreach ($deptsids as $deptsid) { $result .= '<li>'; $result .= $nodes[$deptsid]['dept_name']; if (count($nodes[$deptsid]['childs'] > 0)) { $result .= getSubtreeHTMLList($nodes[$deptsid]['childs'], $nodes); } $result .= '</li>'; } $result .= '</ul>'; return $result; } echo getSubtreeHTMLList($roots, $nodes); ?>

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.120.0100.01120.61
8.4.110.0060.00322.56
8.4.100.0070.00817.94
8.4.90.0140.00718.77
8.4.80.0080.00817.92
8.4.70.0030.00518.16
8.4.60.0120.00819.07
8.4.50.0120.00818.77
8.4.40.0130.00619.70
8.4.30.0090.00617.91
8.4.20.0170.00318.06
8.4.10.0050.00517.80
8.3.250.0110.00818.91
8.3.240.0120.00616.74
8.3.230.0130.00716.66
8.3.220.0060.00417.08
8.3.210.0100.01016.71
8.3.200.0080.00316.76
8.3.190.0100.00717.20
8.3.180.0060.00216.89
8.3.170.0110.00717.23
8.3.160.0100.01018.49
8.3.150.0040.00420.71
8.3.140.0030.00717.26
8.3.130.0080.00018.51
8.3.120.0090.00620.54
8.3.110.0000.00820.94
8.3.100.0090.00024.06
8.3.90.0060.00326.77
8.3.80.0000.00917.97
8.3.70.0090.00617.00
8.3.60.0100.01016.50
8.3.50.0120.00822.02
8.3.40.0070.00718.82
8.3.30.0140.00018.79
8.3.20.0040.00419.29
8.3.10.0040.00421.73
8.3.00.0040.00420.96
8.2.290.0100.00820.59
8.2.280.0090.00918.50
8.2.270.0120.00617.48
8.2.260.0040.00416.82
8.2.250.0060.00316.96
8.2.240.0120.00618.84
8.2.230.0000.00922.58
8.2.220.0130.00337.54
8.2.210.0110.00726.77
8.2.200.0000.01018.41
8.2.190.0160.00618.18
8.2.180.0090.01218.68
8.2.170.0140.00322.96
8.2.160.0070.00720.39
8.2.150.0000.00824.18
8.2.140.0040.00424.66
8.2.130.0140.00426.16
8.2.120.0090.00020.46
8.2.110.0100.00020.52
8.2.100.0090.00317.78
8.2.90.0000.00819.34
8.2.80.0040.00417.97
8.2.70.0050.00317.75
8.2.60.0040.00417.68
8.2.50.0040.00418.10
8.2.40.0060.00320.35
8.2.30.0080.00020.53
8.2.20.0000.00717.77
8.2.10.0040.00418.08
8.2.00.0000.00718.07
8.1.330.0130.00521.73
8.1.320.0150.00716.53
8.1.310.0120.00618.27
8.1.300.0110.00719.83
8.1.290.0030.00618.88
8.1.280.0090.00625.92
8.1.270.0040.00423.70
8.1.260.0140.00426.35
8.1.250.0000.00728.09
8.1.240.0030.00622.08
8.1.230.0080.00420.87
8.1.220.0000.00817.74
8.1.210.0040.00418.77
8.1.200.0090.00017.25
8.1.190.0000.00817.35
8.1.180.0000.00818.10
8.1.170.0000.00818.64
8.1.160.0050.00319.09
8.1.150.0070.00018.86
8.1.140.0040.00419.52
8.1.130.0000.00717.73
8.1.120.0070.00017.47
8.1.110.0040.00417.52
8.1.100.0070.00017.36
8.1.90.0040.00417.47
8.1.80.0070.00017.53
8.1.70.0040.00417.46
8.1.60.0040.00417.60
8.1.50.0040.00417.59
8.1.40.0040.00417.44
8.1.30.0000.00817.59
8.1.20.0040.00417.68
8.1.10.0040.00417.50
8.1.00.0000.00817.55
8.0.300.0070.00018.77
8.0.290.0060.00316.88
8.0.280.0000.00718.43
8.0.270.0070.00017.16
8.0.260.0030.00317.29
8.0.250.0080.00016.93
8.0.240.0000.00717.07
8.0.230.0040.00417.03
8.0.220.0070.00017.05
8.0.210.0030.00316.97
8.0.200.0030.00317.00
8.0.190.0000.00816.98
8.0.180.0030.00917.04
8.0.170.0030.00517.08
8.0.160.0000.00717.04
8.0.150.0000.00716.89
8.0.140.0000.00716.77
8.0.130.0000.00513.40
8.0.120.0000.00816.93
8.0.110.0070.00016.88
8.0.100.0080.00016.87
8.0.90.0040.00416.88
8.0.80.0040.01116.99
8.0.70.0080.00016.96
8.0.60.0000.00716.77
8.0.50.0040.00416.76
8.0.30.0110.00917.25
8.0.20.0170.00217.40
8.0.10.0040.00416.93
8.0.00.0130.00316.63
7.4.330.0030.00316.80
7.4.320.0030.00316.55
7.4.300.0000.00716.69
7.4.290.0030.00316.44
7.4.280.0020.00516.54
7.4.270.0030.00316.57
7.4.260.0000.00716.52
7.4.250.0000.00816.26
7.4.240.0000.00716.64
7.4.230.0040.00416.72
7.4.220.0120.01216.63
7.4.210.0060.00816.58
7.4.200.0000.00816.54
7.4.160.0040.01216.56
7.4.150.0110.00717.40
7.4.140.0090.01017.86
7.4.130.0060.01416.58
7.4.120.0080.01216.58
7.4.110.0140.01016.48
7.4.100.0160.00616.48
7.4.90.0110.00716.69
7.4.80.0060.01219.39
7.4.70.0040.01216.55
7.4.60.0080.00816.65
7.4.50.0030.01416.29
7.4.40.0130.00316.59
7.4.30.0130.00316.48
7.4.00.0030.01315.07
7.3.330.0070.00013.26
7.3.320.0000.00513.44
7.3.310.0030.00316.29
7.3.300.0030.00316.44
7.3.290.0080.00816.42
7.3.280.0070.00916.44
7.3.270.0130.01017.40
7.3.260.0100.00716.52
7.3.250.0080.01116.48
7.3.240.0040.01316.45
7.3.230.0130.00416.52
7.3.210.0060.01616.48
7.3.200.0130.00416.68
7.3.190.0070.01016.57
7.3.180.0180.00416.46
7.3.170.0070.01416.49
7.3.160.0180.00316.48
7.3.30.0090.00614.88
7.3.20.2810.00014.82
7.3.10.0100.00816.10
7.3.00.0300.01016.04
7.2.330.0120.00616.66
7.2.320.0060.01516.71
7.2.310.0110.00716.54
7.2.300.0090.00616.73
7.2.290.0060.01716.63
7.2.160.0100.01415.03
7.2.151.1220.01015.15
7.2.140.0400.00314.89
7.2.130.0110.01216.22
7.2.120.2530.00616.24
7.2.110.0460.01116.22
7.2.100.0170.00916.17
7.2.90.0690.00716.32
7.2.80.0060.01516.33
7.2.70.0960.00416.28
7.2.60.0120.00916.43
7.2.50.0080.00816.27
7.2.40.1130.00716.39
7.2.30.0990.00616.37
7.2.20.0760.00816.35
7.2.10.0810.00716.38
7.2.00.0600.00616.93
7.1.271.2530.01313.82
7.1.260.0130.01014.02
7.1.250.0230.00814.97
7.1.240.0260.01014.16
7.1.230.0870.01713.74
7.1.220.1340.00313.86
7.1.210.0220.00313.92
7.1.200.0110.00514.87
7.1.190.0430.00913.82
7.1.180.3340.00313.83
7.1.170.0580.00714.05
7.1.160.3000.01714.11
7.1.150.2810.00714.17
7.1.140.2360.00013.88
7.1.130.2240.01014.02
7.1.120.1760.02014.13
7.1.110.2340.01013.88
7.1.100.1280.00516.10
7.1.90.1190.01314.16
7.1.80.1250.00913.89
7.1.70.0540.00615.68
7.1.60.0560.01115.54
7.1.50.0440.00915.47
7.1.40.0540.00815.10
7.1.30.0390.01015.24
7.1.20.0460.01015.30
7.1.10.0400.00915.45
7.1.00.0790.00715.48
7.0.330.0760.00613.45
7.0.320.3460.01013.53
7.0.310.0170.00913.72
7.0.300.1870.01013.61
7.0.290.3030.00313.54
7.0.280.2340.00313.52
7.0.270.2050.00713.67
7.0.260.2070.01013.59
7.0.250.2090.00313.68
7.0.240.2420.00713.59
7.0.230.1520.01013.77
7.0.220.4380.01713.51
7.0.210.1040.00913.43
7.0.200.0550.00315.29
7.0.190.0620.00415.04
7.0.180.0470.00814.97
7.0.170.0490.00815.04
7.0.160.0430.00715.06
7.0.150.0500.00615.15
7.0.140.0460.00514.97
7.0.130.0450.00815.08
7.0.120.0450.00415.10
7.0.110.0340.00815.04
7.0.100.0390.00415.04
7.0.90.0420.00914.95
7.0.80.0360.00514.95
7.0.70.0430.00315.05
7.0.60.0420.00615.05
7.0.50.0370.00615.16
7.0.40.0390.00515.06
7.0.30.0410.00314.92
7.0.20.0310.00815.03
7.0.10.0310.00715.01
7.0.00.0350.00915.12
5.6.400.0140.00414.60
5.6.390.0120.00814.15
5.6.380.0040.01514.26
5.6.370.0150.00314.64
5.6.360.0100.01414.67
5.6.350.0080.01714.61
5.6.340.0220.00314.68
5.6.330.0100.01414.73
5.6.320.0150.00414.29
5.6.310.0140.01014.51
5.6.300.0070.02917.56
5.6.290.0070.02617.65
5.6.280.0110.02417.68
5.6.270.0110.03217.59
5.6.260.0070.02617.71
5.6.250.0080.02517.73
5.6.240.0070.02917.86
5.6.230.0080.03617.64
5.6.220.0050.02717.75
5.6.210.0100.02617.72
5.6.200.0090.03017.78
5.6.190.0160.03517.72
5.6.180.0140.02417.74
5.6.170.0050.02817.62
5.6.160.0070.02817.62
5.6.150.0090.02617.73
5.6.140.0080.02617.66
5.6.130.0070.02617.61
5.6.120.0070.03317.74
5.6.110.0140.03017.55
5.6.100.0110.02017.71
5.6.90.0080.03417.68
5.6.80.0130.01917.19
5.6.70.0080.02917.27
5.6.60.0100.02517.38
5.6.50.0130.02717.24
5.6.40.0050.04817.37
5.6.30.0080.04117.26
5.6.20.0080.02317.39
5.6.10.0050.03017.26
5.6.00.0050.02817.31
5.5.380.0120.01816.11
5.5.370.0100.02216.15
5.5.360.0060.02616.04
5.5.350.0080.02615.91
5.5.340.0050.02816.28
5.5.330.0130.02716.30
5.5.320.0100.02316.10
5.5.310.0060.02816.16
5.5.300.0110.02416.20
5.5.290.0110.03416.26
5.5.280.0100.02816.12
5.5.270.0120.02316.12
5.5.260.0070.04716.36
5.5.250.0110.02416.02
5.5.240.0050.03715.91
5.5.230.0090.02116.04
5.5.220.0070.02215.93
5.5.210.0070.02915.99
5.5.200.0110.03615.87
5.5.190.0100.02115.71
5.5.180.0140.02415.83
5.5.170.0120.00814.15
5.5.160.0120.02615.93
5.5.150.0100.02915.64
5.5.140.0030.03015.96
5.5.130.0120.02415.88
5.5.120.0060.02916.00
5.5.110.0110.03215.78
5.5.100.0120.02315.83
5.5.90.0120.02515.91
5.5.80.0080.02815.91
5.5.70.0150.02415.76
5.5.60.0170.02915.82
5.5.50.0170.02815.76
5.5.40.0240.02116.02
5.5.30.0100.02015.73
5.5.20.0100.02215.85
5.5.10.0080.02915.94
5.5.00.0100.02415.92

preferences:
30.45 ms | 403 KiB | 5 Q