3v4l.org

run code in 300+ PHP versions simultaneously
<?php // The hierarcical structure of the categories is: // // Domain // - Category // - - Subcategory class simulating_categories_object{ public $id; public $parent; public $slug; function __construct($id,$parent,$slug){ $this->id = $id; $this->parent = $parent; $this->slug = $slug; } } global $catobj; $catobj = []; $catobj[] = new simulating_categories_object(1,0,'domain1'); $catobj[] = new simulating_categories_object(2,0,'domain2'); $catobj[] = new simulating_categories_object(3,0,'domain3'); $catobj[] = new simulating_categories_object(4,1,'category1'); $catobj[] = new simulating_categories_object(5,1,'category2'); $catobj[] = new simulating_categories_object(6,1,'category3'); $catobj[] = new simulating_categories_object(7,4,'subcategory1'); $catobj[] = new simulating_categories_object(8,4,'subcategory2'); $catobj[] = new simulating_categories_object(9,2,'category555'); $catobj[] = new simulating_categories_object(10,9,'subcategory666'); $catobj[] = new simulating_categories_object(11,3,'category777'); function get_the_parent_id_of_a_given_element_id($id){ global $catobj; foreach($catobj as $category){ if($category->id == $id) return $category->parent; } } echo "<pre>"; //print_r($catobj); echo "</pre>"; foreach($catobj as $element) { if($element->parent == 0){ // our $element is a domain. echo "This element is a domain. The slug of the element is ".$element->slug."<br>"; continue; } $element_parent_id = get_the_parent_id_of_a_given_element_id($element->parent); if($element_parent_id == 0){ // our $element is a category echo "This element is a category. The slug of the element is ".$element->slug."<br>"; continue; } $element_parent_parent_id = get_the_parent_id_of_a_given_element_id($element_parent_id); if($element_parent_parent_id == 0){ // our $element is a subcategory echo "This element is a subcategory. The slug of the element is ".$element->slug."<br>"; } } $result = ['domain1' => [ 'category1' => ['subcategory1','subcategory2'], 'category2' => [], 'category3' => [] ], 'domain2' => [ 'category555' => ['subcategory666'] ], 'domain3' => [ 'category777' => [] ] ]; echo "<pre>"; print_r($result); echo "</pre>";

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.0120.00616.50
8.3.50.0130.00621.98
8.3.40.0120.00318.71
8.3.30.0150.00019.04
8.3.20.0140.00320.28
8.3.10.0040.00423.52
8.3.00.0000.00819.38
8.2.180.0120.00318.21
8.2.170.0040.01122.96
8.2.160.0000.01420.48
8.2.150.0080.00024.18
8.2.140.0060.00324.66
8.2.130.0100.01026.16
8.2.120.0000.00822.26
8.2.110.0110.00022.16
8.2.100.0000.01117.78
8.2.90.0080.00019.21
8.2.80.0050.00318.03
8.2.70.0040.00417.49
8.2.60.0050.00317.93
8.2.50.0080.00018.07
8.2.40.0040.00418.15
8.2.30.0000.00818.22
8.2.20.0030.00517.88
8.2.10.0040.00418.20
8.2.00.0030.00517.73
8.1.280.0140.00725.92
8.1.270.0050.00324.01
8.1.260.0000.00826.35
8.1.250.0050.00328.09
8.1.240.0040.00423.96
8.1.230.0110.00019.10
8.1.220.0040.00417.74
8.1.210.0040.00418.77
8.1.200.0000.01017.47
8.1.190.0030.00617.65
8.1.180.0040.00418.10
8.1.170.0040.00818.55
8.1.160.0040.00422.07
8.1.150.0080.00018.73
8.1.140.0000.00717.46
8.1.130.0000.00717.88
8.1.120.0080.00017.53
8.1.110.0040.00417.41
8.1.100.0000.00717.37
8.1.90.0000.00717.52
8.1.80.0000.00817.41
8.1.70.0080.00017.38
8.1.60.0000.01117.52
8.1.50.0000.00917.56
8.1.40.0040.00417.57
8.1.30.0050.00317.55
8.1.20.0060.00317.75
8.1.10.0040.00417.59
8.1.00.0060.00317.45
8.0.300.0000.00718.77
8.0.290.0070.00017.29
8.0.280.0030.00318.61
8.0.270.0000.00717.23
8.0.260.0070.00016.79
8.0.250.0000.00717.05
8.0.240.0060.00317.05
8.0.230.0060.00316.99
8.0.220.0030.00316.96
8.0.210.0030.00316.91
8.0.200.0030.00717.04
8.0.190.0080.00016.96
8.0.180.0030.00516.94
8.0.170.0040.00416.99
8.0.160.0040.00417.02
8.0.150.0040.00416.98
8.0.140.0060.00316.88
8.0.130.0030.00313.34
8.0.120.0050.00316.82
8.0.110.0030.00516.92
8.0.100.0060.00317.07
8.0.90.0050.00316.79
8.0.80.0120.00316.97
8.0.70.0050.00317.02
8.0.60.0080.00017.02
8.0.50.0030.00616.96
8.0.30.0100.01017.19
8.0.20.0120.00717.41
8.0.10.0000.00817.08
8.0.00.0110.00816.82
7.4.330.0030.00315.02
7.4.320.0030.00316.52
7.4.300.0000.00616.51
7.4.290.0080.00016.68
7.4.280.0080.00316.64
7.4.270.0030.00416.61
7.4.260.0030.00316.62
7.4.250.0040.00416.52
7.4.240.0020.00516.62
7.4.230.0070.00016.47
7.4.220.0090.00916.61
7.4.210.0070.00816.62
7.4.200.0000.00716.55
7.4.190.0000.00716.83
7.4.160.0080.00816.71
7.4.150.0090.00917.40
7.4.140.0190.01817.86
7.4.130.0150.01116.52
7.4.120.0080.01216.52
7.4.110.0070.01516.69
7.4.100.0090.01316.61
7.4.90.0060.01316.46
7.4.80.0120.00619.39
7.4.70.0160.00516.55
7.4.60.0100.00716.52
7.4.50.0040.00016.66
7.4.40.0100.00322.77
7.4.30.0100.00616.65
7.4.00.0030.01014.76
7.3.330.0050.00013.21
7.3.320.0030.00313.28
7.3.310.0000.00716.32
7.3.300.0030.00316.33
7.3.290.0110.00416.34
7.3.280.0110.00816.30
7.3.270.0150.00617.40
7.3.260.0170.00716.37
7.3.250.0170.00516.42
7.3.240.0130.00316.62
7.3.230.0090.00916.59
7.3.210.0060.01216.43
7.3.200.0090.01419.39
7.3.190.0170.00616.28
7.3.180.0100.00716.64
7.3.170.0100.01016.31
7.3.160.0040.01516.70
7.3.120.0040.01114.86
7.3.10.0070.00716.87
7.3.00.0120.00316.41
7.2.330.0100.01016.96
7.2.320.0110.00616.59
7.2.310.0080.00816.65
7.2.300.0070.01116.73
7.2.290.0070.01016.90
7.2.130.0030.01217.14
7.2.120.0080.00817.06
7.2.110.0040.00716.77
7.2.100.0080.00817.11
7.2.90.0040.01117.04
7.2.80.0070.00316.86
7.2.70.0070.00716.91
7.2.60.0090.00416.89
7.2.50.0000.01416.70
7.2.40.0060.00916.38
7.2.30.0090.01216.86
7.2.20.0080.00816.88
7.2.10.0100.01616.84
7.2.00.0020.01418.03
7.1.250.0030.01015.85
7.1.200.0090.00615.66
7.1.100.0070.00717.98
7.1.70.0070.00317.29
7.1.60.0040.00819.33
7.1.50.0070.01316.69
7.1.00.0070.07322.28
7.0.200.0000.00716.73
7.0.140.0070.06721.92
7.0.100.0370.06319.93
7.0.90.0400.08719.97
7.0.80.0370.08319.84
7.0.70.0300.07719.88
7.0.60.0100.08020.05
7.0.50.0230.08020.34
7.0.40.0100.08020.10
7.0.30.0070.08719.99
7.0.20.0030.08720.14
7.0.10.0070.08320.05
7.0.00.0100.04720.09
5.6.280.0070.07020.87
5.6.250.0030.08320.70
5.6.240.0100.06720.65
5.6.230.0130.07320.48
5.6.220.0130.07320.50
5.6.210.0070.08020.44
5.6.200.0200.07321.06
5.6.190.0130.04320.93
5.6.180.0070.08320.91
5.6.170.0100.08020.95
5.6.160.0100.08021.11
5.6.150.0170.06721.15
5.6.140.0130.07720.90
5.6.130.0000.08320.92
5.6.120.0030.07721.02
5.6.110.0130.07721.05
5.6.100.0030.05720.99
5.6.90.0130.07720.92
5.6.80.0170.07320.48
5.6.70.0030.07320.46
5.6.60.0070.07320.43
5.6.50.0000.06320.33
5.6.40.0070.07720.41
5.6.30.0130.07020.43
5.6.20.0000.06320.39
5.6.10.0170.07320.36
5.6.00.0030.08320.25
5.5.380.0100.07720.38
5.5.370.0070.07720.33
5.5.360.0200.07320.41
5.5.350.0030.08320.43
5.5.340.0070.08020.89
5.5.330.0070.05720.88
5.5.320.0130.06720.82
5.5.310.0030.08720.86
5.5.300.0100.08020.89
5.5.290.0130.07720.84
5.5.280.0100.08020.84
5.5.270.0070.08020.65
5.5.260.0100.07720.71
5.5.250.0230.06320.63
5.5.240.0000.08720.25
5.5.230.0100.08319.96
5.5.220.0070.08320.27
5.5.210.0070.08020.19
5.5.200.0070.07720.11
5.5.190.0070.07320.11
5.5.180.0130.07020.09
5.5.160.0100.07020.19
5.5.150.0100.07720.25
5.5.140.0100.07320.26
5.5.130.0070.08019.96
5.5.120.0100.04020.11
5.5.110.0070.08020.05
5.5.100.0070.07720.03
5.5.90.0100.07320.13
5.5.80.0070.07319.92
5.5.70.0130.08720.13
5.5.60.0130.07320.04
5.5.50.0130.07020.01
5.5.40.0030.09320.13
5.5.30.0100.07719.97
5.5.20.0130.07720.05
5.5.10.0030.04720.00
5.5.00.0000.05719.95
5.4.450.0100.07719.37
5.4.440.0030.05019.38
5.4.430.0070.08019.18
5.4.420.0130.07019.48
5.4.410.0070.05319.08
5.4.400.0000.07719.04
5.4.390.0000.05018.91
5.4.380.0130.06719.24
5.4.370.0070.08019.21
5.4.360.0030.07719.14
5.4.350.0030.04319.04
5.4.340.0100.04019.14
5.4.320.0130.07318.88
5.4.310.0070.08019.05
5.4.300.0030.07719.03
5.4.290.0070.04319.21
5.4.280.0100.07319.14
5.4.270.0070.06719.03
5.4.260.0200.06719.03
5.4.250.0070.04719.20
5.4.240.0100.06319.03
5.4.230.0030.08319.20
5.4.220.0070.08019.18
5.4.210.0130.05718.86
5.4.200.0130.07019.14
5.4.190.0070.07319.13
5.4.180.0100.04719.03
5.4.170.0070.03719.23
5.4.160.0030.06319.11
5.4.150.0030.05318.93
5.4.140.0000.04016.51
5.4.130.0030.03716.44
5.4.120.0070.04016.47
5.4.110.0030.03716.52
5.4.100.0000.04016.54
5.4.90.0030.04016.55
5.4.80.0030.03716.53
5.4.70.0000.05016.38
5.4.60.0030.03316.31
5.4.50.0000.03716.43
5.4.40.0130.02716.43
5.4.30.0030.03716.34
5.4.20.0170.03716.46
5.4.10.0030.03716.36
5.4.00.0070.03315.80
5.3.290.0030.04314.80
5.3.280.0070.07014.63
5.3.270.0030.05014.64
5.3.260.0030.03714.53
5.3.250.0000.04314.59
5.3.240.0000.04014.67
5.3.230.0030.04314.62
5.3.220.0070.03314.62
5.3.210.0000.04014.55
5.3.200.0070.03014.58
5.3.190.0030.03714.70
5.3.180.0000.04014.70
5.3.170.0030.03714.65
5.3.160.0130.05014.49
5.3.150.0100.03014.55
5.3.140.0000.04014.63
5.3.130.0030.03714.48
5.3.120.0030.03714.64
5.3.110.0030.05314.52
5.3.100.0000.04014.18
5.3.90.0000.04314.02
5.3.80.0070.03314.14
5.3.70.0000.05014.09
5.3.60.0100.03313.92
5.3.50.0070.04314.09
5.3.40.0000.04013.96
5.3.30.0070.04713.92
5.3.20.0030.03713.75
5.3.10.0070.03013.75
5.3.00.0030.04013.77
5.2.170.0070.03311.21
5.2.160.0030.02711.04
5.2.150.0030.03011.04
5.2.140.0030.02711.28
5.2.130.0030.03011.00
5.2.120.0030.02710.99
5.2.110.0030.02711.02
5.2.100.0000.03011.20
5.2.90.0000.03011.17
5.2.80.0000.03011.21
5.2.70.0030.03311.19
5.2.60.0000.02710.91
5.2.50.0000.03011.09
5.2.40.0030.03011.06
5.2.30.0070.02310.90
5.2.20.0030.02311.03
5.2.10.0000.03010.98
5.2.00.0030.02710.79
5.1.60.0030.02710.12
5.1.50.0030.02010.09
5.1.40.0030.02310.05
5.1.30.0000.02310.46
5.1.20.0070.03310.29
5.1.10.0000.02310.12
5.1.00.0000.02710.07
5.0.50.0000.0178.58
5.0.40.0030.0238.51
5.0.30.0030.0308.34
5.0.20.0000.0208.31
5.0.10.0030.0438.31
5.0.00.0030.0478.31
4.4.90.0000.0178.31
4.4.80.0000.0178.31
4.4.70.0000.0178.31
4.4.60.0030.0138.31
4.4.50.0030.0138.31
4.4.40.0000.0238.31
4.4.30.0030.0138.31
4.4.20.0030.0138.31
4.4.10.0000.0208.31
4.4.00.0000.0208.31
4.3.110.0030.0138.31
4.3.100.0000.0138.31
4.3.90.0030.0138.31
4.3.80.0030.0508.31
4.3.70.0000.0338.31
4.3.60.0000.0378.31
4.3.50.0030.0378.31
4.3.40.0030.0438.31
4.3.30.0000.0378.31
4.3.20.0000.0308.31
4.3.10.0000.0278.31
4.3.00.0030.0308.31

preferences:
48.16 ms | 401 KiB | 5 Q