3v4l.org

run code in 300+ PHP versions simultaneously
<?php // The hierarcical structure of the categories is: // // Domain // - Category // - - Subcategory class simulating_categories_object{ var $id; var $parent; var $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.0090.00616.88
8.3.50.0160.01216.44
8.3.40.0040.01218.84
8.3.30.0070.00718.87
8.3.20.0050.00318.73
8.3.10.0040.00418.77
8.3.00.0050.00519.38
8.2.180.0040.01116.63
8.2.170.0060.00922.96
8.2.160.0130.00319.04
8.2.150.0040.00424.18
8.2.140.0050.00324.66
8.2.130.0080.00026.16
8.2.120.0000.00721.03
8.2.110.0060.00321.04
8.2.100.0090.00317.91
8.2.90.0040.00419.24
8.2.80.0060.00617.97
8.2.70.0000.00817.50
8.2.60.0080.00017.93
8.2.50.0000.00818.03
8.2.40.0050.00319.48
8.2.30.0030.00617.86
8.2.20.0110.00017.70
8.2.10.0030.00617.78
8.2.00.0040.00417.73
8.1.270.0080.00023.99
8.1.260.0040.00426.35
8.1.250.0040.00428.09
8.1.240.0060.00322.82
8.1.230.0070.00317.95
8.1.220.0040.00417.74
8.1.210.0050.00318.77
8.1.200.0090.00017.47
8.1.190.0000.00817.21
8.1.180.0040.00418.10
8.1.170.0040.00417.62
8.1.160.0040.00419.05
8.1.150.0030.00618.70
8.1.140.0070.00017.54
8.1.130.0030.00317.55
8.1.120.0070.00317.50
8.1.110.0040.00417.55
8.1.100.0000.00817.38
8.1.90.0000.00717.57
8.1.80.0050.00317.43
8.1.70.0000.00817.52
8.1.60.0040.00417.53
8.1.50.0030.00517.41
8.1.40.0040.00417.43
8.1.30.0030.00617.65
8.1.20.0030.00617.67
8.1.10.0030.00617.66
8.1.00.0030.00517.41
8.0.300.0040.00418.77
8.0.290.0070.00016.75
8.0.280.0000.00718.68
8.0.270.0000.00717.33
8.0.260.0070.00016.86
8.0.250.0070.00016.95
8.0.240.0030.00317.04
8.0.230.0040.00416.93
8.0.220.0030.00316.97
8.0.210.0030.00516.94
8.0.200.0000.00717.07
8.0.190.0000.00716.90
8.0.180.0030.00516.85
8.0.170.0000.00816.92
8.0.160.0000.00717.02
8.0.150.0090.00016.79
8.0.140.0060.00616.85
8.0.130.0000.00613.38
8.0.120.0050.00316.88
8.0.110.0070.00016.74
8.0.100.0030.00516.89
8.0.90.0070.00016.78
8.0.80.0120.00916.98
8.0.70.0070.00016.83
8.0.60.0030.00517.00
8.0.50.0060.00316.84
8.0.30.0030.01217.10
8.0.20.0160.00417.24
8.0.10.0050.00216.91
8.0.00.0100.00816.73
7.4.330.0060.00013.15
7.4.320.0000.00616.66
7.4.300.0000.00616.54
7.4.290.0040.00416.56
7.4.280.0030.00316.57
7.4.270.0070.00016.59
7.4.260.0030.00313.27
7.4.250.0000.00816.53
7.4.240.0000.00816.52
7.4.230.0070.00016.68
7.4.220.0110.01116.54
7.4.210.0080.01516.69
7.4.200.0000.00716.68
7.4.190.0000.00816.59
7.4.160.0160.00716.49
7.4.150.0080.01116.39
7.4.140.0160.00717.86
7.4.130.0130.00716.68
7.4.120.0150.00316.56
7.4.110.0070.01616.59
7.4.100.0120.00616.57
7.4.90.0090.00916.61
7.4.80.0120.00619.39
7.4.70.0090.00916.54
7.4.60.0030.01316.59
7.4.50.0000.00616.40
7.4.40.0130.00316.56
7.4.30.0100.00616.62
7.4.10.0030.01716.19
7.4.00.0120.00515.51
7.3.330.0040.00413.36
7.3.320.0030.00313.18
7.3.310.0000.00716.36
7.3.300.0020.00516.30
7.3.290.0060.01316.39
7.3.280.0120.00916.32
7.3.270.0120.00616.41
7.3.260.0080.00916.75
7.3.240.0170.00016.66
7.3.230.0100.00716.46
7.3.210.0060.01016.65
7.3.200.0060.01216.39
7.3.190.0150.00016.39
7.3.180.0090.00616.71
7.3.170.0120.00516.55
7.3.160.0060.00916.70
7.3.130.0080.01216.31
7.3.120.0080.00915.53
7.3.110.0090.00316.57
7.3.100.0000.01516.58
7.3.90.0090.00616.56
7.3.80.0030.00916.67
7.3.70.0100.00316.36
7.3.60.0070.01116.37
7.3.50.0000.01516.41
7.3.40.0040.00816.09
7.3.30.0050.00516.48
7.3.20.0060.00918.05
7.3.10.0030.01017.45
7.3.00.0070.00717.32
7.2.330.0170.00016.71
7.2.320.0070.01116.83
7.2.310.0120.00916.57
7.2.300.0130.00316.67
7.2.290.0120.00416.79
7.2.260.0130.00316.52
7.2.250.0060.01316.62
7.2.240.0070.00716.79
7.2.230.0060.01216.71
7.2.220.0100.00616.45
7.2.210.0110.00316.55
7.2.200.0030.01416.64
7.2.190.0070.01016.64
7.2.180.0030.01316.63
7.2.170.0040.01516.54
7.2.160.0040.00816.68
7.2.150.0060.00918.50
7.2.140.0060.00918.38
7.2.130.0020.01317.68
7.2.120.0050.00917.61
7.2.110.0060.00917.68
7.2.100.0110.00417.69
7.2.90.0100.00417.51
7.2.80.0030.01317.60
7.2.70.0070.00517.70
7.2.60.0020.01117.77
7.2.50.0110.00417.62
7.2.40.0060.00717.80
7.2.30.0080.00717.72
7.2.20.0070.00617.85
7.2.10.0080.00817.75
7.2.00.0050.00718.33
7.1.330.0060.00917.27
7.1.320.0060.00617.64
7.1.310.0060.00617.62
7.1.300.0040.01117.37
7.1.290.0080.00417.44
7.1.280.0040.01117.30
7.1.270.0000.01217.30
7.1.260.0040.01417.31
7.1.250.0050.00716.50
7.1.240.0030.01017.14
7.1.230.0040.01117.43
7.1.220.0030.00717.33
7.1.210.0090.00917.27
7.1.200.0040.01117.35
7.1.190.0030.00917.50
7.1.180.0030.00717.20
7.1.170.0030.00917.39
7.1.160.0070.00317.17
7.1.150.0030.00717.31
7.1.140.0090.00617.48
7.1.130.0000.01417.34
7.1.120.0040.00817.38
7.1.110.0040.01217.43
7.1.100.0050.00917.52
7.1.90.0040.01117.37
7.1.80.0080.00317.59
7.1.70.0000.00917.21
7.1.60.0090.01218.29
7.1.50.0030.01017.03
7.1.40.0090.00617.29
7.1.30.0030.00917.26
7.1.20.0060.00917.26
7.1.10.0140.00017.58
7.1.00.0050.04219.93
7.0.330.0060.00317.07
7.0.320.0000.01717.15
7.0.310.0070.01117.11
7.0.300.0030.00916.98
7.0.290.0040.01116.88
7.0.280.0070.01017.01
7.0.270.0110.00417.18
7.0.260.0050.00517.01
7.0.250.0070.00716.91
7.0.240.0070.01017.06
7.0.230.0030.00617.03
7.0.220.0050.00917.00
7.0.210.0040.01417.02
7.0.200.0040.00916.75
7.0.190.0030.01217.05
7.0.180.0030.01216.93
7.0.170.0120.00017.08
7.0.160.0090.00617.07
7.0.150.0060.00917.11
7.0.140.0030.04519.51
7.0.130.0070.00717.10
7.0.120.0020.04519.48
7.0.110.0050.04119.66
7.0.100.0070.03219.52
7.0.90.0050.04419.45
7.0.80.0050.03719.50
7.0.70.0090.03919.53
7.0.60.0090.03819.41
7.0.50.0020.04319.58
7.0.40.0030.03618.50
7.0.30.0030.04118.48
7.0.20.0050.04118.51
7.0.10.0060.04018.48
7.0.00.0080.03318.52
5.6.400.0070.01016.16
5.6.390.0040.01116.21
5.6.380.0030.01316.38
5.6.370.0090.00616.08
5.6.360.0040.01115.97
5.6.350.0110.00416.12
5.6.340.0130.00016.05
5.6.330.0070.01115.91
5.6.320.0070.00716.04
5.6.310.0070.00315.99
5.6.300.0060.01116.25
5.6.290.0110.00415.87
5.6.280.0130.00715.88
5.6.270.0070.01015.84
5.6.260.0080.03518.55
5.6.250.0080.03318.40
5.6.240.0020.04518.46
5.6.230.0080.03718.44
5.6.220.0050.04218.39
5.6.210.0020.04218.45
5.6.200.0050.03918.48
5.6.190.0050.04218.50
5.6.180.0070.04118.48
5.6.170.0030.04318.50
5.6.160.0070.03218.47
5.6.150.0060.04018.58
5.6.140.0110.03718.39
5.6.130.0100.03518.39
5.6.120.0070.04518.65
5.6.110.0100.04018.48
5.6.100.0070.04418.42
5.6.90.0070.04318.38
5.6.80.0060.04318.13
5.6.70.0090.03518.11
5.6.60.0030.03818.19
5.6.50.0050.03618.16
5.6.40.0060.03718.13
5.6.30.0020.04618.15
5.6.20.0040.04418.07
5.6.10.0080.03718.03
5.6.00.0070.03718.18
5.5.380.0090.03716.81
5.5.370.0050.03716.82
5.5.360.0080.03816.73
5.5.350.0070.03916.67
5.5.340.0040.04616.90
5.5.330.0070.04016.95
5.5.320.0050.04216.87
5.5.310.0110.03716.95
5.5.300.0070.03917.21
5.5.290.0130.03516.97
5.5.280.0100.04117.03
5.5.270.0060.04516.98
5.5.260.0100.04217.02
5.5.250.0020.04316.84
5.5.240.0090.03216.67
5.5.230.0020.04116.67
5.5.220.0020.03716.79
5.5.210.0050.04016.77
5.5.200.0040.04016.63
5.5.190.0040.03916.57
5.5.180.0050.04216.78
5.5.170.0060.01015.82
5.5.160.0050.03816.68
5.5.150.0080.03316.68
5.5.140.0060.03716.81
5.5.130.0070.03816.79
5.5.120.0070.03716.68
5.5.110.0020.03816.73
5.5.100.0040.03916.64
5.5.90.0050.03516.53
5.5.80.0020.03316.55
5.5.70.0060.03816.52
5.5.60.0070.02816.57
5.5.50.0080.03516.48
5.5.40.0060.03716.56
5.5.30.0020.04016.64
5.5.20.0060.03816.41
5.5.10.0090.03516.46
5.5.00.0030.03916.56
5.4.450.0050.04016.01
5.4.440.0060.04316.06
5.4.430.0020.04216.03
5.4.420.0050.04116.11
5.4.410.0020.04416.09
5.4.400.0040.03716.00
5.4.390.0030.03315.96
5.4.380.0020.03715.96
5.4.370.0030.03215.98
5.4.360.0060.03515.97
5.4.350.0050.03715.96
5.4.340.0050.03715.91
5.4.330.0000.01112.69
5.4.320.0070.03515.86
5.4.310.0060.03315.85
5.4.300.0030.04015.84
5.4.290.0030.03115.97
5.4.280.0060.03816.05
5.4.270.0030.04015.95
5.4.260.0030.03615.92
5.4.250.0070.03316.02
5.4.240.0030.03715.88
5.4.230.0070.03516.02
5.4.220.0040.03716.00
5.4.210.0100.03216.08
5.4.200.0050.03715.85
5.4.190.0050.03815.95
5.4.180.0050.03815.88
5.4.170.0030.03815.84
5.4.160.0060.03515.95
5.4.150.0040.03615.82
5.4.140.0050.03714.62
5.4.130.0030.03714.63
5.4.120.0050.02914.64
5.4.110.0040.03814.73
5.4.100.0030.02614.74
5.4.90.0070.03214.71
5.4.80.0060.03314.63
5.4.70.0020.03714.70
5.4.60.0070.03314.58
5.4.50.0050.03514.63
5.4.40.0040.03614.78
5.4.30.0030.03614.66
5.4.20.0030.03614.64
5.4.10.0070.03514.73
5.4.00.0050.03514.35
5.3.290.0050.03813.80
5.3.280.0030.03613.71
5.3.270.0030.03913.76
5.3.260.0030.03613.78
5.3.250.0050.03413.76
5.3.240.0050.03313.75
5.3.230.0030.03813.65
5.3.220.0060.03313.62
5.3.210.0020.03913.62
5.3.200.0030.03313.82
5.3.190.0030.03513.67
5.3.180.0010.03613.80
5.3.170.0040.03413.76
5.3.160.0030.03513.69
5.3.150.0050.03413.68
5.3.140.0060.03313.73
5.3.130.0050.03613.71
5.3.120.0030.04013.70
5.3.110.0030.03413.70
5.3.100.0000.03813.46
5.3.90.0020.03913.49
5.3.80.0050.03313.41
5.3.70.0000.04213.42
5.3.60.0070.03113.44
5.3.50.0020.03613.35
5.3.40.0080.03213.32
5.3.30.0010.03813.37
5.3.20.0050.03113.26
5.3.10.0050.03313.22
5.3.00.0060.03513.21
5.2.170.0030.05711.23
5.2.160.0000.05711.17
5.2.150.0030.05711.13
5.2.140.0000.05711.12
5.2.130.0000.05711.11
5.2.120.0030.05011.24
5.2.110.0000.04311.25
5.2.100.0030.05311.09
5.2.90.0000.05311.10
5.2.80.0070.05011.06
5.2.70.0000.05311.11
5.2.60.0000.05711.19
5.2.50.0030.05710.88
5.2.40.0030.05311.01
5.2.30.0030.05710.96
5.2.20.0000.04710.97
5.2.10.0030.05010.84
5.2.00.0030.05010.95
5.1.60.0000.04010.25
5.1.50.0000.0409.98
5.1.40.0000.04710.06
5.1.30.0070.03710.20
5.1.20.0070.04710.35
5.1.10.0000.04310.07
5.1.00.0000.05010.06
5.0.50.0030.0379.70
5.0.40.0000.0339.70
5.0.30.0000.0579.70
5.0.20.0070.0339.70
5.0.10.0000.0409.70
5.0.00.0000.0609.70
4.4.90.0030.0239.70
4.4.80.0030.0279.70
4.4.70.0000.0309.70
4.4.60.0030.0279.70
4.4.50.0000.0279.70
4.4.40.0000.0479.70
4.4.30.0030.0209.70
4.4.20.0000.0309.70
4.4.10.0030.0239.70
4.4.00.0000.0479.70
4.3.110.0000.0339.70
4.3.100.0000.0309.70
4.3.90.0070.0239.70
4.3.80.0000.0409.70
4.3.70.0030.0279.70
4.3.60.0000.0309.70
4.3.50.0000.0279.70
4.3.40.0000.0409.70
4.3.30.0000.0309.70
4.3.20.0000.0309.70
4.3.10.0000.0279.70
4.3.00.0030.0279.70

preferences:
57.45 ms | 400 KiB | 5 Q