3v4l.org

run code in 300+ PHP versions simultaneously
<?php class CategoryTree { private $catTree = array(); public function addCategory($category, $parent) { if($parent == null){ if(count(array_column($this->catTree, 'category', $category)) > 0){ echo 'Duplicate category'; } else{ $temp = array("category" => $category,"parent" => $parent); array_push($this->catTree,$temp); } } else{ echo 'Parent: ' . $parent; print_r(count(array_column($this->catTree, 'category'), $parent)); } } public function getChildren($parent) { $that = $this; $keys = array_keys(array_column($this->catTree, 'parent'), $parent); return array_map(function($k) use ($that){return $that->catTree[$k]['category'];}, $keys); } } // For testing purposes (do not submit uncommented): $c = new CategoryTree; $c->addCategory('A', null); $c->addCategory('A', null); $c->addCategory('B', 'A'); $c->addCategory('B', 'D'); $c->addCategory('C', 'A'); echo implode(',', $c->getChildren('A'));

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.0070.01018.43
8.3.50.0120.00721.08
8.3.40.0110.00418.81
8.3.30.0070.01518.71
8.3.20.0080.00020.37
8.3.10.0060.00023.61
8.3.00.0040.00423.49
8.2.180.0090.01216.88
8.2.170.0150.00322.96
8.2.160.0070.00720.38
8.2.150.0080.00024.18
8.2.140.0050.00324.66
8.2.130.0000.00819.95
8.2.120.0050.00326.35
8.2.110.0060.00320.97
8.2.100.0040.00817.84
8.2.90.0040.00419.04
8.2.80.0040.00417.97
8.2.70.0030.00617.75
8.2.60.0000.00818.16
8.2.50.0030.00518.07
8.2.40.0040.00422.27
8.2.30.0040.00419.53
8.2.20.0000.00717.89
8.2.10.0070.00018.25
8.2.00.0050.00218.01
8.1.280.0060.00925.92
8.1.270.0040.01120.21
8.1.260.0040.00428.09
8.1.250.0050.00228.09
8.1.240.0090.00022.30
8.1.230.0110.00022.68
8.1.220.0000.00817.74
8.1.210.0030.00718.77
8.1.200.0050.00517.35
8.1.190.0040.00417.25
8.1.180.0060.00318.10
8.1.170.0040.00418.37
8.1.160.0040.00420.73
8.1.150.0000.00718.85
8.1.140.0030.00519.59
8.1.130.0000.00717.62
8.1.120.0000.00717.55
8.1.110.0000.00717.52
8.1.100.0000.00717.50
8.1.90.0040.00417.44
8.1.80.0000.00717.45
8.1.70.0030.00317.45
8.1.60.0060.00317.51
8.1.50.0060.00317.57
8.1.40.0080.00017.43
8.1.30.0030.00517.67
8.1.20.0000.00917.60
8.1.10.0020.00517.49
8.1.00.0040.00417.53
8.0.300.0000.00818.77
8.0.290.0070.00016.88
8.0.280.0030.00318.45
8.0.270.0040.00417.21
8.0.260.0000.00617.30
8.0.250.0030.00516.95
8.0.240.0000.00616.98
8.0.230.0000.00717.00
8.0.220.0000.00816.86
8.0.210.0000.00816.96
8.0.200.0030.00317.02
8.0.190.0040.00417.00
8.0.180.0070.00017.00
8.0.170.0000.00816.85
8.0.160.0000.00816.91
8.0.150.0030.00317.03
8.0.140.0030.00516.93
8.0.130.0030.00313.39
8.0.120.0030.00516.91
8.0.110.0040.00417.03
8.0.100.0000.00716.95
8.0.90.0040.00417.00
8.0.80.0060.00916.86
8.0.70.0040.00416.99
8.0.60.0000.00716.82
8.0.50.0000.00716.79
8.0.30.0110.01017.06
8.0.20.0070.01217.40
8.0.10.0000.00817.10
8.0.00.0120.00816.94
7.4.330.0030.00316.71
7.4.320.0000.00716.61
7.4.300.0040.00416.61
7.4.290.0000.00716.44
7.4.280.0060.00316.65
7.4.270.0030.00616.55
7.4.260.0030.00316.62
7.4.250.0000.00916.58
7.4.240.0030.00516.51
7.4.230.0000.00716.48
7.4.220.0070.01016.65
7.4.210.0110.00416.50
7.4.200.0000.00716.41
7.4.160.0000.01516.41
7.4.150.0100.00717.40
7.4.140.0110.00717.86
7.4.130.0110.00816.53
7.4.120.0050.01116.44
7.4.110.0130.00316.51
7.4.100.0090.00916.57
7.4.90.0110.00716.50
7.4.80.0110.01119.39
7.4.70.0130.00716.71
7.4.60.0100.00616.52
7.4.50.0090.00616.72
7.4.40.0060.01216.57
7.4.30.0030.01316.70
7.4.00.0000.01414.65
7.3.330.0050.00013.31
7.3.320.0030.00513.26
7.3.310.0040.00416.39
7.3.300.0030.00316.31
7.3.290.0070.00916.44
7.3.280.0070.01116.41
7.3.270.0030.01417.40
7.3.260.0170.00016.36
7.3.250.0080.01016.35
7.3.240.0140.00916.60
7.3.230.0090.00916.55
7.3.210.0150.00416.44
7.3.200.0000.01719.39
7.3.190.0070.01016.63
7.3.180.0070.01016.53
7.3.170.0100.00616.63
7.3.160.0080.00816.46
7.3.00.0030.01216.69
7.2.330.0200.00316.47
7.2.320.0070.01716.77
7.2.310.0120.00316.87
7.2.300.0040.01616.66
7.2.290.0090.00616.55
7.2.130.0070.00716.87
7.2.120.0050.00516.94
7.2.110.0080.00316.77
7.2.100.0100.00316.91
7.2.90.0070.01016.60
7.2.80.0000.01117.02
7.2.70.0060.00616.95
7.2.60.0080.00616.81
7.2.50.0080.00416.97
7.2.40.0040.01117.05
7.2.30.0060.00316.71
7.2.20.0060.00316.91
7.2.10.0030.00916.86
7.2.00.0050.00918.32
7.1.250.0030.01015.83
7.1.240.0030.00615.86
7.1.230.0030.00615.97
7.1.220.0000.01015.64
7.1.210.0030.01115.87
7.1.200.0060.00615.68
7.1.190.0030.00715.80
7.1.180.0030.01015.98
7.1.170.0120.00315.60
7.1.160.0040.00415.94
7.1.150.0090.00015.70
7.1.140.0000.01415.86
7.1.130.0040.00715.81
7.1.120.0070.00415.89
7.1.110.0000.01215.66
7.1.100.0030.00816.92
7.1.90.0050.00315.53
7.1.80.0000.01015.79
7.1.70.0030.00716.57
7.1.60.0090.00917.50
7.1.50.0070.00416.15
7.1.40.0030.00715.82
7.1.30.0040.00815.73
7.1.20.0030.01015.87
7.1.10.0090.00315.80
7.1.00.0040.04219.09
7.0.330.0000.00815.29
7.0.320.0030.00715.25
7.0.310.0060.00315.37
7.0.300.0030.00715.33
7.0.290.0100.00015.44
7.0.280.0080.00315.21
7.0.270.0000.01115.41
7.0.260.0030.00815.46
7.0.250.0030.00615.57
7.0.240.0000.01515.46
7.0.230.0030.00615.43
7.0.220.0070.00715.49
7.0.210.0000.01015.33
7.0.200.0060.00515.88
7.0.190.0030.00915.54
7.0.180.0060.00615.27
7.0.170.0030.00715.47
7.0.160.0080.00415.34
7.0.150.0040.00715.51
7.0.140.0070.00315.46
7.0.130.0030.00615.51
7.0.120.0040.00815.37
7.0.110.0070.00315.58
7.0.100.0030.00915.59
7.0.90.0050.00515.44
7.0.80.0000.00915.50
7.0.70.0030.01015.46
7.0.60.0110.04318.37
7.0.50.0050.02216.68
7.0.40.0050.02616.84
7.0.30.0150.03016.73
7.0.20.0120.04016.70
7.0.10.0060.02316.63
7.0.00.0060.02216.70
5.6.380.0100.00014.20
5.6.370.0110.00014.27
5.6.360.0030.01014.60
5.6.350.0030.00714.48
5.6.340.0000.00914.55
5.6.330.0000.01114.45
5.6.320.0070.00413.97
5.6.310.0000.01014.61
5.6.300.0070.00313.92
5.6.290.0030.00714.37
5.6.280.0070.03317.66
5.6.270.0060.00614.09
5.6.260.0000.01014.27
5.6.250.0060.00314.27
5.6.240.0080.00314.42
5.6.230.0100.00313.90
5.6.220.0030.01014.11
5.6.210.0060.02117.55
5.6.200.0070.02816.37
5.6.190.0040.03917.37
5.6.180.0150.02917.35
5.6.170.0150.04217.30
5.6.160.0080.02517.40
5.6.150.0070.03716.29
5.6.140.0050.02216.22
5.6.130.0030.04316.25
5.6.120.0050.03317.73
5.6.110.0070.02017.77
5.6.100.0070.04217.60
5.6.90.0100.04217.56
5.6.80.0050.04417.21
5.6.70.0050.00514.13
5.6.60.0090.00614.43
5.6.50.0060.00614.02
5.6.40.0100.00014.18
5.6.30.0070.00713.90
5.6.20.0000.01114.25
5.6.10.0030.00713.79
5.6.00.0040.00714.00
5.5.380.0060.00011.23
5.5.370.0040.00411.03
5.5.360.0000.00711.05
5.5.350.0030.04315.89
5.5.340.0070.02914.70
5.5.330.0080.02515.88
5.5.320.0130.03515.75
5.5.310.0130.04115.80
5.5.300.0080.02514.60
5.5.290.0030.03414.63
5.5.280.0030.03016.04
5.5.270.0080.02815.91
5.5.260.0050.04316.08
5.5.250.0060.02615.84
5.5.240.0070.04215.76
5.5.230.0060.00611.06
5.5.220.0050.00310.91
5.5.210.0050.00211.06
5.5.200.0070.00011.14
5.5.190.0040.00711.18
5.5.180.0000.00711.10
5.5.170.0000.00811.24
5.5.160.0030.00311.13
5.5.150.0040.00411.09
5.5.140.0040.00411.21
5.5.130.0000.00811.26
5.5.120.0030.00610.98
5.5.110.0070.00011.21
5.5.100.0040.00411.02
5.5.90.0030.00311.16
5.5.80.0070.00011.16
5.5.70.0000.00711.23
5.5.60.0070.00411.23
5.5.50.0080.00011.08
5.5.40.0090.00010.90
5.5.30.0040.00410.95
5.5.20.0030.00611.14
5.5.10.0040.00411.01
5.5.00.0030.00611.16

preferences:
46.33 ms | 401 KiB | 5 Q