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, &$result = array()) { $sub_categories = tep_get_subcategories($category_id); // no sub categories found:return self as result if (count($sub_categories) === 0) { $result[] = $category_id; } else { foreach ($sub_categories as $category_id) { tep_get_leaf_categories($category_id, $result); } } return $result; }

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.70.0110.00418.30
8.3.60.0120.00316.38
8.3.50.0130.00622.10
8.3.40.0040.01418.73
8.3.30.0000.01418.92
8.3.20.0000.00720.14
8.3.10.0040.00421.89
8.3.00.0060.00320.93
8.2.180.0090.00616.63
8.2.170.0090.00622.96
8.2.160.0070.00722.11
8.2.150.0040.00424.18
8.2.140.0090.00024.66
8.2.130.0090.00026.16
8.2.120.0000.00726.16
8.2.110.0090.00022.18
8.2.100.0040.00817.52
8.2.90.0000.00817.72
8.2.80.0030.00517.97
8.2.70.0060.00317.49
8.2.60.0050.00517.80
8.2.50.0000.00918.07
8.2.40.0040.00418.03
8.2.30.0070.00017.86
8.2.20.0000.00717.53
8.2.10.0050.00317.83
8.2.00.0000.00717.49
8.1.280.0120.00625.92
8.1.270.0060.00320.55
8.1.260.0040.00426.35
8.1.250.0000.00828.09
8.1.240.0040.00422.09
8.1.230.0080.00420.82
8.1.220.0040.00417.74
8.1.210.0000.00818.77
8.1.200.0040.00717.23
8.1.190.0000.00817.10
8.1.180.0060.00318.10
8.1.170.0000.00918.51
8.1.160.0050.00222.00
8.1.150.0050.00218.71
8.1.140.0030.00517.32
8.1.130.0030.00317.84
8.1.120.0000.00717.36
8.1.110.0030.00617.38
8.1.100.0050.00217.23
8.1.90.0000.00717.24
8.1.80.0040.00417.27
8.1.70.0000.00717.40
8.1.60.0030.00517.46
8.1.50.0090.00017.32
8.1.40.0040.00417.37
8.1.30.0040.00417.47
8.1.20.0000.00817.55
8.1.10.0040.00417.25
8.1.00.0030.00617.38
8.0.300.0050.00219.78
8.0.290.0080.00016.58
8.0.280.0000.00818.24
8.0.270.0000.00717.05
8.0.260.0040.00417.05
8.0.250.0030.00316.75
8.0.240.0000.00716.86
8.0.230.0040.00416.75
8.0.220.0030.00316.70
8.0.210.0000.00716.82
8.0.200.0100.00016.91
8.0.190.0050.00316.82
8.0.180.0000.00716.76
8.0.170.0030.00516.73
8.0.160.0030.00316.76
8.0.150.0000.00716.77
8.0.140.0040.00416.68
8.0.130.0050.00013.19
8.0.120.0040.00416.64
8.0.110.0000.00716.77
8.0.100.0000.00716.73
8.0.90.0000.00716.73
8.0.80.0120.00916.82
8.0.70.0040.00416.73
8.0.60.0080.00016.69
8.0.50.0050.00316.61
8.0.30.0160.00616.97
8.0.20.0150.01117.40
8.0.10.0040.00416.77
8.0.00.0140.00316.58
7.4.330.0030.00315.03
7.4.320.0080.00016.38
7.4.300.0030.00316.48
7.4.290.0040.00416.40
7.4.280.0040.00416.38
7.4.270.0070.00016.45
7.4.260.0000.00716.27
7.4.250.0070.00016.34
7.4.240.0070.00216.45
7.4.230.0000.00716.47
7.4.220.0110.00616.42
7.4.210.0060.00916.45
7.4.200.0060.00316.23
7.4.160.0030.01716.25
7.4.150.0120.00617.40
7.4.140.0090.01017.86
7.4.130.0090.01116.33
7.4.120.0080.00916.28
7.4.110.0140.00816.32
7.4.100.0100.00716.34
7.4.90.0140.00316.37
7.4.80.0140.00316.20
7.4.70.0060.01016.41
7.4.60.0100.00616.51
7.4.50.0030.00516.32
7.4.40.0070.01316.27
7.4.30.0150.00316.20
7.4.00.0080.00515.09
7.3.330.0050.00013.06
7.3.320.0120.00013.11
7.3.310.0030.00316.24
7.3.300.0050.00316.11
7.3.290.0060.00916.20
7.3.280.0080.00816.19
7.3.270.0030.01717.40
7.3.260.0140.00916.21
7.3.250.0080.00816.37
7.3.240.0090.00916.13
7.3.230.0080.01216.44
7.3.210.0100.00716.21
7.3.200.0090.01219.39
7.3.190.0150.00016.28
7.3.180.0070.01116.07
7.3.170.0120.00616.27
7.3.160.0170.00616.29
7.3.00.0090.00616.57
7.2.330.0090.00916.36
7.2.320.0140.00716.40
7.2.310.0110.01116.54
7.2.300.0090.00616.58
7.2.290.0060.01016.41
7.2.130.0070.00316.46
7.2.120.0100.00716.82
7.2.110.0030.01016.51
7.2.100.0030.00716.48
7.2.90.0030.00616.38
7.2.80.0110.00416.73
7.2.70.0070.00416.69
7.2.60.0040.00416.68
7.2.50.0000.01416.85
7.2.40.0110.00316.85
7.2.30.0100.00316.82
7.2.20.0090.00316.86
7.2.10.0040.01116.45
7.2.00.0030.01118.01
7.1.250.0060.00615.43
7.1.240.0030.00815.77
7.1.230.0070.00715.71
7.1.220.0040.01115.50
7.1.210.0030.01015.71
7.1.200.0040.00415.65
7.1.190.0030.00915.80
7.1.180.0000.00915.55
7.1.170.0030.00615.57
7.1.160.0080.00315.66
7.1.150.0040.00715.68
7.1.140.0030.00915.64
7.1.130.0040.01115.63
7.1.120.0080.00815.63
7.1.110.0030.01015.41
7.1.100.0030.01016.68
7.1.90.0040.00715.68
7.1.80.0020.00715.42
7.1.70.0030.00616.34
7.1.60.0060.01117.52
7.1.50.0080.01116.29
7.1.40.0070.01015.55
7.1.30.0040.01115.45
7.1.20.0030.00915.34
7.1.10.0030.01015.74
7.1.00.0050.04219.13
7.0.330.0060.01015.25
7.0.320.0040.00815.22
7.0.310.0080.00315.39
7.0.300.0000.01015.21
7.0.290.0030.00615.24
7.0.280.0050.00515.21
7.0.270.0060.00915.21
7.0.260.0100.00315.27
7.0.250.0090.00315.02
7.0.240.0070.00415.36
7.0.230.0000.00715.22
7.0.220.0040.00815.43
7.0.210.0030.01015.07
7.0.200.0180.00314.92
7.0.190.0070.00315.09
7.0.180.0090.00615.25
7.0.170.0070.00715.18
7.0.160.0080.00415.25
7.0.150.0080.00315.18
7.0.140.0070.01818.65
7.0.130.0080.00715.20
7.0.120.0000.00915.42
7.0.110.0030.00615.43
7.0.100.0030.03717.59
7.0.90.0030.04517.56
7.0.80.0150.03617.59
7.0.70.0130.04317.62
7.0.60.0080.04017.50
7.0.50.0030.03817.88
7.0.40.0040.04516.80
7.0.30.0070.04616.59
7.0.20.0050.03016.56
7.0.10.0060.02816.69
7.0.00.0100.02516.69
5.6.380.0040.01114.00
5.6.370.0000.01114.19
5.6.360.0060.00613.87
5.6.350.0070.00714.16
5.6.340.0060.00614.13
5.6.330.0090.00614.23
5.6.320.0070.00713.88
5.6.310.0000.01214.32
5.6.300.0040.00814.04
5.6.290.0110.00013.82
5.6.280.0120.04117.36
5.6.270.0100.00314.16
5.6.260.0060.01014.23
5.6.250.0070.02617.36
5.6.240.0000.03117.50
5.6.230.0050.04917.34
5.6.220.0130.03617.29
5.6.210.0070.04417.37
5.6.200.0060.04017.61
5.6.190.0110.03417.49
5.6.180.0050.02717.55
5.6.170.0070.04717.59
5.6.160.0080.03017.69
5.6.150.0100.04217.59
5.6.140.0090.02717.50
5.6.130.0050.04117.62
5.6.120.0110.03717.45
5.6.110.0080.04017.52
5.6.100.0080.03817.43
5.6.90.0100.04017.63
5.6.80.0080.02817.32
5.6.70.0060.02417.13
5.6.60.0110.03617.13
5.6.50.0100.03117.17
5.6.40.0050.03317.10
5.6.30.0030.02317.18
5.6.20.0020.03117.13
5.6.10.0050.02017.20
5.6.00.0050.03617.06
5.5.380.0090.02115.71
5.5.370.0070.04215.63
5.5.360.0060.03815.71
5.5.350.0080.04515.72
5.5.340.0050.02315.98
5.5.330.0050.02515.91
5.5.320.0030.02615.85
5.5.310.0070.02515.92
5.5.300.0080.04015.95
5.5.290.0080.03915.93
5.5.280.0110.04015.87
5.5.270.0050.03315.99
5.5.260.0070.02715.84
5.5.250.0130.03815.82
5.5.240.0000.03815.63
5.5.230.0120.04015.55
5.5.220.0070.02515.53
5.5.210.0050.04715.60
5.5.200.0070.03015.50
5.5.190.0060.03815.53
5.5.180.0030.04515.56
5.5.170.0040.00810.90
5.5.160.0050.03615.66
5.5.150.0030.02315.60
5.5.140.0050.03715.57
5.5.130.0050.03415.53
5.5.120.0050.03815.58
5.5.110.0060.04115.60
5.5.100.0040.04015.53
5.5.90.0100.01815.51
5.5.80.0110.03115.48
5.5.70.0030.02215.42
5.5.60.0050.03815.50
5.5.50.0030.02715.48
5.5.40.0070.03115.57
5.5.30.0040.02915.48
5.5.20.0110.03015.49
5.5.10.0050.02315.49
5.5.00.0050.03015.50
5.4.450.0020.03715.14
5.4.440.0030.02715.07
5.4.430.0110.03615.19
5.4.420.0030.04315.17
5.4.410.0050.04014.98
5.4.400.0110.01814.88
5.4.390.0050.04015.01
5.4.380.0070.03314.90
5.4.370.0080.03714.90
5.4.360.0030.02115.03
5.4.350.0040.03215.03
5.4.340.0050.03715.00
5.4.330.0000.00910.90
5.4.320.0090.03915.06
5.4.310.0060.04015.02
5.4.300.0070.03514.99
5.4.290.0040.02114.99
5.4.280.0020.02314.88
5.4.270.0000.02415.05
5.4.260.0050.04115.03
5.4.250.0020.04415.07
5.4.240.0040.02715.04
5.4.230.0070.03114.97
5.4.220.0050.03014.87
5.4.210.0000.03314.96
5.4.200.0070.02214.87
5.4.190.0080.03615.02
5.4.180.0070.03715.03
5.4.170.0020.02514.89
5.4.160.0050.04115.04
5.4.150.0090.02514.99
5.4.140.0050.04113.56
5.4.130.0000.03113.70
5.4.120.0110.02413.68
5.4.110.0030.03513.66
5.4.100.0070.02013.65
5.4.90.0050.02513.72
5.4.80.0050.04013.69
5.4.70.0050.03113.64
5.4.60.0070.03513.60
5.4.50.0050.04213.63
5.4.40.0050.02413.68
5.4.30.0070.03813.66
5.4.20.0070.04013.58
5.4.10.0070.02513.67
5.4.00.0040.02413.41
5.3.290.0030.02912.77
5.3.280.0060.04112.73
5.3.270.0050.03212.74
5.3.260.0050.04112.74
5.3.250.0030.03712.81
5.3.240.0000.04712.72
5.3.230.0030.02312.76
5.3.220.0030.02412.71
5.3.210.0070.02212.80
5.3.200.0050.02112.70
5.3.190.0060.02012.70
5.3.180.0040.03012.80
5.3.170.0140.01712.71
5.3.160.0070.02812.72
5.3.150.0070.03912.79
5.3.140.0050.03412.69
5.3.130.0060.03512.69
5.3.120.0100.03312.71
5.3.110.0090.03612.76
5.3.100.0040.04412.45
5.3.90.0070.02412.45
5.3.80.0030.03912.46
5.3.70.0070.01712.51
5.3.60.0070.01812.48
5.3.50.0080.01712.42
5.3.40.0080.03512.47
5.3.30.0020.04012.41
5.3.20.0000.02312.33
5.3.10.0030.04012.33
5.3.00.0000.03912.26
5.2.170.0050.03011.09
5.2.160.0030.03211.07
5.2.150.0050.03211.04
5.2.140.0030.01510.97
5.2.130.0040.01510.99
5.2.120.0050.03111.04
5.2.110.0050.01811.05
5.2.100.0030.03311.00
5.2.90.0070.02811.05
5.2.80.0070.02911.03
5.2.70.0080.02810.96
5.2.60.0030.02510.98
5.2.50.0090.02510.96
5.2.40.0030.02810.90
5.2.30.0040.02710.97
5.2.20.0010.03510.89
5.2.10.0030.01710.96
5.2.00.0100.02210.88
5.1.60.0020.02810.79
5.1.50.0030.02510.79
5.1.40.0000.01710.79
5.1.30.0040.03010.79
5.1.20.0000.03310.79
5.1.10.0020.02110.79
5.1.00.0050.01810.79
5.0.50.0070.02410.79
5.0.40.0030.02310.79
5.0.30.0050.02810.79
5.0.20.0030.01110.79
5.0.10.0000.02810.79
5.0.00.0070.01510.79
4.4.90.0050.01610.79
4.4.80.0000.01810.79
4.4.70.0020.01710.79
4.4.60.0030.01510.79
4.4.50.0030.01510.79
4.4.40.0010.01610.79
4.4.30.0000.01710.79
4.4.20.0040.01710.79
4.4.10.0000.01010.79
4.4.00.0020.02110.79
4.3.110.0020.01010.79
4.3.100.0000.01510.79
4.3.90.0000.02010.79
4.3.80.0000.02210.79
4.3.70.0000.01710.79
4.3.60.0020.01110.79
4.3.50.0020.01010.79
4.3.40.0020.02710.79
4.3.30.0030.01010.79
4.3.20.0020.01510.79
4.3.10.0000.01910.79
4.3.00.0010.01610.79

preferences:
77.11 ms | 401 KiB | 5 Q