3v4l.org

run code in 300+ PHP versions simultaneously
<?php // I have a table `categoreis` to store products' categories information // it use categories_id and parent_id to identify the level relationship between those categories // now I want a function(tep_get_leaf_categories() below) to get all leaf categories for a passed in category_id // say tep_get_leaf_categories(360) will get all leaf categories id as an array of category 360 // this function get all subcategories, or child-categories for $category_id function tep_get_subcategories($category_id) { $subcategories_raw = tep_db_query('SELECT ca.categories_id FROM categories ca LEFT JOIN categoreis cb ON ca.parent_id = cb.categories_id WHERE cb.categoreis_id = ' . (int) $category_id); $subcategories = array(); if (mysql_num_rows($subcategories_raw) >= 1) { while ($row = mysql_fetch_assoc($subcategories_raw)) { $category_id = $row['categories_id']; $subcategories[] = $category_id; } } return $subcategories; } // this is the function that I'm working on, to get the leaf category of $category_id function tep_get_leaf_categories($category_id) { $sub_categories = tep_get_subcategories($category_id); // no sub categories found:return self as result if (count($sub_categories) === 0) { return array($category_id); } else { foreach ($sub_categories as $category_id) { tep_get_leaf_categories($category_id); // what next? } } }

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.0190.00016.63
8.3.50.0180.00222.06
8.3.40.0110.00318.57
8.3.30.0100.00718.93
8.3.20.0050.00220.35
8.3.10.0080.00021.73
8.3.00.0030.00618.94
8.2.180.0090.01218.29
8.2.170.0140.00022.96
8.2.160.0140.00320.58
8.2.150.0080.00024.18
8.2.140.0000.00824.66
8.2.130.0040.00426.16
8.2.120.0080.00019.70
8.2.110.0050.00522.17
8.2.100.0090.00317.72
8.2.90.0040.00419.10
8.2.80.0000.00817.97
8.2.70.0050.00317.50
8.2.60.0040.00417.80
8.2.50.0040.00418.07
8.2.40.0080.00018.04
8.2.30.0070.00017.87
8.2.20.0040.00417.66
8.2.10.0000.00817.95
8.2.00.0040.00417.49
8.1.280.0200.00025.92
8.1.270.0060.00318.75
8.1.260.0040.00426.35
8.1.250.0070.00028.09
8.1.240.0070.01420.56
8.1.230.0060.00617.58
8.1.220.0030.00617.74
8.1.210.0060.00318.77
8.1.200.0060.00317.23
8.1.190.0090.00017.10
8.1.180.0030.00618.10
8.1.170.0060.00318.71
8.1.160.0000.00718.79
8.1.150.0000.00718.66
8.1.140.0000.00717.31
8.1.130.0000.00717.66
8.1.120.0030.00517.25
8.1.110.0000.00817.36
8.1.100.0070.00017.38
8.1.90.0070.00017.32
8.1.80.0000.00717.27
8.1.70.0070.00017.25
8.1.60.0030.00617.54
8.1.50.0000.00817.48
8.1.40.0040.00417.33
8.1.30.0000.00817.42
8.1.20.0000.00817.60
8.1.10.0040.00417.25
8.1.00.0030.00617.34
8.0.300.0040.00418.77
8.0.290.0040.00416.58
8.0.280.0070.00018.39
8.0.270.0000.00717.02
8.0.260.0000.00617.14
8.0.250.0030.00316.79
8.0.240.0030.00316.82
8.0.230.0040.00416.75
8.0.220.0030.00316.75
8.0.210.0030.00316.81
8.0.200.0000.00816.74
8.0.190.0050.00316.85
8.0.180.0000.00716.70
8.0.170.0040.00416.85
8.0.160.0050.00216.92
8.0.150.0000.00716.70
8.0.140.0040.00416.61
8.0.130.0030.00313.14
8.0.120.0000.00916.79
8.0.110.0040.00416.82
8.0.100.0040.00416.67
8.0.90.0030.00616.72
8.0.80.0160.00616.74
8.0.70.0040.00416.71
8.0.60.0040.00416.86
8.0.50.0030.00516.76
8.0.30.0130.01117.05
8.0.20.0150.01917.40
8.0.10.0050.00316.95
8.0.00.0110.00616.49
7.4.330.0000.00515.03
7.4.320.0030.00316.41
7.4.300.0030.00316.50
7.4.290.0000.00716.51
7.4.280.0030.00616.48
7.4.270.0030.00316.51
7.4.260.0000.00716.36
7.4.250.0030.00316.34
7.4.240.0020.00516.51
7.4.230.0030.00316.14
7.4.220.0000.00716.23
7.4.210.0100.01016.51
7.4.200.0000.00816.52
7.4.160.0040.01116.69
7.4.150.0040.01217.40
7.4.140.0100.01017.86
7.4.130.0130.00516.29
7.4.120.0070.01016.39
7.4.110.0090.01216.55
7.4.100.0070.01016.27
7.4.90.0090.00916.67
7.4.80.0120.01219.39
7.4.70.0130.01016.41
7.4.60.0110.00516.34
7.4.50.0090.00016.04
7.4.40.0130.00316.25
7.4.30.0140.00916.32
7.4.00.0070.00714.71
7.3.330.0030.00313.06
7.3.320.0040.00813.20
7.3.310.0000.00716.26
7.3.300.0000.00716.11
7.3.290.0000.00716.20
7.3.280.0080.01216.18
7.3.270.0180.00017.40
7.3.260.0110.01116.03
7.3.250.0100.00716.31
7.3.240.0130.00416.10
7.3.230.0100.01316.39
7.3.210.0120.00416.37
7.3.200.0100.00616.22
7.3.190.0030.01216.31
7.3.180.0150.00616.33
7.3.170.0220.00016.48
7.3.160.0090.01316.41
7.3.10.0080.00516.67
7.3.00.0070.00716.44
7.2.330.0100.00716.60
7.2.320.0030.01316.29
7.2.310.0090.00916.31
7.2.300.0090.00616.34
7.2.290.0100.00716.42
7.2.130.0070.00616.54
7.2.120.0050.00716.67
7.2.110.0100.00316.40
7.2.100.0060.00716.53
7.2.90.0090.01216.55
7.2.80.0040.00916.70
7.2.70.0100.00616.63
7.2.60.0080.00616.60
7.2.50.0040.01216.52
7.2.40.0020.01116.55
7.2.30.0040.01016.61
7.2.20.0130.00316.52
7.2.10.0110.00716.57
7.2.00.0060.01017.54
7.1.250.0030.00715.53
7.1.200.0220.00015.36
7.1.100.0100.01017.87
7.1.70.0050.00516.66
7.1.60.0180.00719.46
7.1.50.0100.01316.81
7.1.00.0070.07322.33
7.0.200.0510.00314.69
7.0.140.0000.03722.15
7.0.60.0100.04720.09
7.0.50.0000.09317.86
7.0.40.0030.04720.13
7.0.30.0200.03720.21
7.0.20.0270.07020.27
7.0.10.0070.07720.22
7.0.00.0070.03720.32
5.6.280.0100.06721.09
5.6.210.0170.07320.52
5.6.200.0030.05018.12
5.6.190.0030.08720.50
5.6.180.3630.04320.51
5.6.170.0270.07320.57
5.6.160.0030.05320.71
5.6.150.0130.07318.19
5.6.140.0100.04018.19
5.6.130.0070.08018.14
5.6.120.0100.07720.97
5.6.110.0100.06321.09
5.6.100.0170.05720.98
5.6.90.0130.08021.04
5.6.80.0170.07020.54
5.6.70.4130.04020.54
5.5.350.0270.06020.31
5.5.340.0170.05718.04
5.5.330.0130.07720.37
5.5.320.0230.03720.30
5.5.310.0370.06720.51
5.5.300.0100.06318.01
5.5.290.0070.05318.07
5.5.280.0170.07020.88
5.5.270.0070.04020.83
5.5.260.0070.04020.85
5.5.250.0070.09320.70
5.5.240.0300.05720.34
5.4.450.0500.05719.43
5.4.440.0700.06319.34
5.4.430.1100.06019.55
5.4.420.1070.04719.36
5.4.410.0770.06019.25
5.4.400.1000.05319.08
5.4.390.0100.06018.80
5.4.380.0200.05018.84
5.4.370.0230.05318.78
5.4.360.0200.05318.75
5.4.350.0270.07318.84
5.4.340.0430.03718.62
5.4.320.0200.07718.74
5.4.310.0270.04718.50
5.4.300.0200.06018.61
5.4.290.0230.04718.61
5.4.280.0170.05318.46
5.4.270.0170.05318.80
5.4.260.0130.05718.77
5.4.250.0200.05018.53
5.4.240.0230.05718.63
5.4.230.0170.05018.52
5.4.220.0270.04018.79
5.4.210.0300.04318.74
5.4.200.0200.04316.57
5.4.190.0200.04718.46
5.4.180.0230.05018.71
5.4.170.0130.05718.73
5.4.160.0170.05718.68
5.4.150.0330.04318.45
5.4.140.0200.06016.45
5.4.130.0200.04716.29
5.4.120.0170.05016.25
5.4.110.0100.06016.48
5.4.100.0200.06316.48
5.4.90.0200.05316.28
5.4.80.0200.05016.28
5.4.70.0200.05016.42
5.4.60.0130.05316.30
5.4.50.0270.03716.14
5.4.40.0170.05316.29
5.4.30.0170.06016.22
5.4.20.0100.05716.30
5.4.10.0100.05316.41
5.4.00.0170.04715.71
5.3.290.0070.06314.67
5.3.280.0200.05014.64
5.3.270.0200.05014.72
5.3.260.0100.06014.65
5.3.250.0130.06314.66
5.3.240.0270.05014.71
5.3.230.0200.05714.71
5.3.220.0230.07014.74
5.3.210.0170.06014.71
5.3.200.0130.08014.70
5.3.190.0300.04714.68
5.3.180.0100.06014.79
5.3.170.0270.04314.62
5.3.160.0130.05314.60
5.3.150.0130.05714.67
5.3.140.0230.05714.58
5.3.130.0170.05314.69
5.3.120.0200.05314.73
5.3.110.0330.06314.69
5.3.100.0230.06714.14
5.3.90.0170.05314.08
5.3.80.0230.04314.09
5.3.70.0270.05714.12
5.3.60.0270.04314.01
5.3.50.0270.04714.06
5.3.40.0230.05014.16
5.3.30.0200.05014.02
5.3.20.0100.05313.70
5.3.10.0200.04313.71
5.3.00.0270.04313.74
5.2.170.0130.04311.27
5.2.160.0130.04311.16
5.2.150.0130.04311.13
5.2.140.0170.04011.24
5.2.130.0170.03711.15
5.2.120.0130.04011.15
5.2.110.0100.04311.13
5.2.100.0100.06011.14
5.2.90.0130.05711.17
5.2.80.0170.05711.23
5.2.70.0300.04311.20
5.2.60.0130.04711.10
5.2.50.0130.04011.13
5.2.40.0170.05010.98
5.2.30.0200.03711.03
5.2.20.0070.04711.18
5.2.10.0130.03710.89
5.2.00.0130.03710.76
5.1.60.0070.04010.20
5.1.50.0130.03010.00
5.1.40.0070.04010.00
5.1.30.0130.04010.36
5.1.20.0200.03010.45
5.1.10.0130.03310.17
5.1.00.0130.03710.12
5.0.50.0100.0308.50
5.0.40.0000.0378.42
5.0.30.0000.0508.27
5.0.20.0030.0308.24
5.0.10.0170.0208.32
5.0.00.0070.0438.21
4.4.90.0030.0275.98
4.4.80.0100.0175.87
4.4.70.0070.0235.92
4.4.60.0070.0205.89
4.4.50.0100.0205.94
4.4.40.0070.0375.92
4.4.30.0100.0235.90
4.4.20.0070.0206.03
4.4.10.0030.0276.06
4.4.00.0070.0405.95
4.3.110.0070.0235.86
4.3.100.0070.0205.86
4.3.90.0030.0235.79
4.3.80.0100.0305.85
4.3.70.0070.0275.79
4.3.60.0170.0205.82
4.3.50.0070.0305.84
4.3.40.0070.0475.75
4.3.30.0130.0234.56
4.3.20.0000.0334.65
4.3.10.0000.0274.54
4.3.00.0230.03314.42

preferences:
45.81 ms | 401 KiB | 5 Q