3v4l.org

run code in 300+ PHP versions simultaneously
<?php class CategoryTree { private $catTree = array(); public function addCategory($category, $parent) { if($parent == null){ echo count(array_column($this->catTree, 'category')); /*if(count(array_column($this->catTree, 'category'), $category) > 0){ echo 'Duplicate category'; }*/ } else{ } $temp = array("category" => $category,"parent" => $parent); array_push($this->catTree,$temp); } 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('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.70.0030.01318.55
8.3.60.0080.00618.43
8.3.50.0120.00722.12
8.3.40.0140.00718.91
8.3.30.0100.00319.05
8.3.20.0030.00620.20
8.3.10.0040.00423.53
8.3.00.0000.00819.68
8.2.190.0060.01116.58
8.2.180.0100.01316.63
8.2.170.0070.01318.94
8.2.160.0110.00422.96
8.2.150.0080.00324.18
8.2.140.0060.00324.66
8.2.130.0000.00826.16
8.2.120.0100.00619.48
8.2.110.0050.00520.53
8.2.100.0070.00418.34
8.2.90.0040.00819.26
8.2.80.0080.00017.97
8.2.70.0040.00417.63
8.2.60.0040.00417.93
8.2.50.0000.00918.07
8.2.40.0000.00819.88
8.2.30.0000.00718.15
8.2.20.0050.00317.65
8.2.10.0000.00718.07
8.2.00.0050.00218.09
8.1.280.0100.00725.92
8.1.270.0080.00020.38
8.1.260.0040.00426.35
8.1.250.0030.00528.09
8.1.240.0070.00322.42
8.1.230.0040.00721.04
8.1.220.0000.00917.74
8.1.210.0040.00418.77
8.1.200.0080.00317.47
8.1.190.0000.00817.23
8.1.180.0050.00318.10
8.1.170.0030.00618.50
8.1.160.0050.00322.04
8.1.150.0000.00718.88
8.1.140.0030.00917.48
8.1.130.0070.00017.89
8.1.120.0040.00417.50
8.1.110.0030.00517.47
8.1.100.0040.00417.48
8.1.90.0030.00517.49
8.1.80.0040.00417.50
8.1.70.0030.00317.46
8.1.60.0030.00617.61
8.1.50.0060.00617.53
8.1.40.0030.00517.55
8.1.30.0080.00017.56
8.1.20.0040.00417.59
8.1.10.0000.00717.58
8.1.00.0040.00417.55
8.0.300.0030.00618.77
8.0.290.0040.00416.75
8.0.280.0000.00718.39
8.0.270.0030.00317.14
8.0.260.0000.00717.31
8.0.250.0000.00716.91
8.0.240.0040.00416.96
8.0.230.0030.00316.88
8.0.220.0070.00016.78
8.0.210.0050.00216.94
8.0.200.0060.00016.83
8.0.190.0030.00516.95
8.0.180.0040.00416.93
8.0.170.0000.00816.90
8.0.160.0040.00416.90
8.0.150.0000.00716.86
8.0.140.0000.00716.77
8.0.130.0030.00513.27
8.0.120.0080.00016.85
8.0.110.0070.00016.73
8.0.100.0040.00416.93
8.0.90.0030.00616.92
8.0.80.0060.01016.82
8.0.70.0040.00416.84
8.0.60.0030.00516.89
8.0.50.0030.00516.77
8.0.30.0120.00717.05
8.0.20.0100.00817.40
8.0.10.0050.00317.05
8.0.00.0100.00716.87
7.4.330.0000.00515.03
7.4.320.0000.00616.65
7.4.300.0000.00616.60
7.4.290.0050.00216.62
7.4.280.0050.00316.65
7.4.270.0070.00016.59
7.4.260.0000.00916.49
7.4.250.0040.00416.63
7.4.240.0020.00616.57
7.4.230.0000.00716.41
7.4.220.0120.00616.55
7.4.210.0070.01616.54
7.4.200.0030.00316.65
7.4.160.0060.00916.63
7.4.150.0000.01717.40
7.4.140.0120.00917.86
7.4.130.0120.00916.49
7.4.120.0110.01116.44
7.4.110.0130.00416.33
7.4.100.0190.00616.38
7.4.90.0100.01016.44
7.4.80.0120.00619.39
7.4.70.0130.00316.52
7.4.60.0070.01016.43
7.4.50.0030.00316.57
7.4.40.0090.01116.64
7.4.30.0090.00916.33
7.4.00.0050.01414.98
7.3.330.0030.00513.41
7.3.320.0000.00513.25
7.3.310.0070.00016.39
7.3.300.0070.00016.42
7.3.290.0080.00616.39
7.3.280.0130.00516.37
7.3.270.0100.01017.40
7.3.260.0030.01516.32
7.3.250.0100.01016.38
7.3.240.0110.00716.63
7.3.230.0110.00816.54
7.3.210.0060.01216.62
7.3.200.0130.00319.39
7.3.190.0110.00516.25
7.3.180.0160.00016.64
7.3.170.0080.00816.39
7.3.160.0110.00416.38
7.3.120.0050.01114.90
7.3.110.0080.00714.99
7.3.100.0060.00814.80
7.3.90.0120.00214.95
7.3.80.0040.01014.86
7.3.70.0040.00714.69
7.3.60.0060.00614.64
7.3.50.0080.00514.92
7.3.40.0070.00514.80
7.3.30.0040.00814.85
7.3.20.0060.00716.52
7.3.10.0070.00716.66
7.3.00.0050.00816.64
7.2.330.0080.01616.71
7.2.320.0090.01216.49
7.2.310.0100.00716.59
7.2.300.0070.01416.61
7.2.290.0180.00616.72
7.2.250.0080.01115.10
7.2.240.0090.00815.21
7.2.230.0060.01014.94
7.2.220.0040.00714.99
7.2.210.0070.00614.96
7.2.200.0080.00715.06
7.2.190.0040.00915.03
7.2.180.0080.00515.09
7.2.170.0010.01215.10
7.2.160.0070.01015.04
7.2.150.0130.00317.02
7.2.140.0040.01216.78
7.2.130.0090.00416.70
7.2.120.0040.01116.91
7.2.110.0100.00617.04
7.2.100.0070.01016.91
7.2.90.0090.00616.68
7.2.80.0070.00716.74
7.2.70.0110.00716.68
7.2.60.0110.00317.00
7.2.50.0040.01516.95
7.2.40.0090.00617.03
7.2.30.0060.00316.88
7.2.20.0030.01216.92
7.2.10.0130.00317.01
7.2.00.0080.00618.27
7.1.330.0050.01015.88
7.1.320.0050.00915.92
7.1.310.0100.00615.77
7.1.300.0060.00715.80
7.1.290.0060.00615.68
7.1.280.0050.00615.77
7.1.270.0070.00615.79
7.1.260.0060.00815.86
7.1.250.0030.01515.79
7.1.200.0030.01015.59
7.1.100.0090.00618.04
7.1.70.0000.00817.20
7.1.60.0150.01119.86
7.1.50.0090.01516.68
7.1.00.0030.07722.40
7.0.200.0080.00815.20
7.0.60.0030.05720.02
7.0.50.0130.07717.93
7.0.40.0030.07320.29
7.0.30.0270.04320.11
7.0.20.0230.04720.29
7.0.10.0070.04320.14
7.0.00.0070.04320.05
5.6.280.0070.06721.16
5.6.210.0100.07720.66
5.6.200.0070.08018.16
5.6.190.0170.07320.48
5.6.180.0530.05320.50
5.6.170.0270.07020.50
5.6.160.0070.08320.50
5.6.150.0030.04318.19
5.6.140.0030.04718.27
5.6.130.0030.04318.14
5.6.120.0070.05320.98
5.6.110.0100.06021.00
5.6.100.0130.05720.98
5.6.90.0070.06320.98
5.6.80.0130.07320.50
5.5.350.0370.06320.48
5.5.340.0070.04018.04
5.5.330.0170.07720.31
5.5.320.0270.03720.24
5.5.310.0370.05320.27
5.5.300.0100.05318.04
5.5.290.0070.07317.95
5.5.280.0070.03720.98
5.5.270.0000.04320.88
5.5.260.0130.07720.80
5.5.250.0200.06720.63
5.5.240.0100.06320.13
5.4.450.0530.06319.71
5.4.440.0770.05019.28
5.4.430.0070.05719.62
5.4.420.0030.06019.68
5.4.410.0100.05319.27
5.4.400.0000.06019.09
5.4.390.0070.05319.07
5.4.380.0030.05719.26
5.4.370.0070.05719.07
5.4.360.0170.06019.12
5.4.350.0100.06019.16
5.4.340.0100.06019.06
5.4.320.0130.06319.08
5.4.310.0000.06019.13
5.4.300.0130.04319.15
5.4.290.0130.04719.13
5.4.280.0030.05719.01
5.4.270.0030.05719.15
5.4.260.0200.04019.25
5.4.250.0100.05018.98
5.4.240.0030.05719.02
5.4.230.0130.04319.12
5.4.220.0100.05019.03
5.4.210.0130.06019.06
5.4.200.0070.05016.64
5.4.190.0030.05719.19
5.4.180.0030.05319.01
5.4.170.0100.06719.24
5.4.160.0200.04719.09
5.4.150.0130.05019.10
5.4.140.0030.05716.47
5.4.130.0170.04316.30
5.4.120.0030.05016.31
5.4.110.0070.04716.59
5.4.100.0100.05316.68
5.4.90.0030.05716.59
5.4.80.0070.06016.61
5.4.70.0070.05016.32
5.4.60.0100.04716.60
5.4.50.0130.04316.59
5.4.40.0200.04016.45
5.4.30.0130.04316.68
5.4.20.0100.04716.40
5.4.10.0070.05016.38
5.4.00.0100.04715.93
5.3.290.0030.05714.71
5.3.280.0000.06014.64
5.3.270.0000.06014.77
5.3.260.0100.05314.53
5.3.250.0170.04314.67
5.3.240.0000.05714.78
5.3.230.0070.05014.57
5.3.220.0130.04314.69
5.3.210.0070.05314.63
5.3.200.0100.04314.52
5.3.190.0200.04014.48
5.3.180.0130.04314.59
5.3.170.0100.04714.72
5.3.160.0030.05314.49
5.3.150.0170.04014.69
5.3.140.0200.05714.48
5.3.130.0070.05314.52
5.3.120.0200.05714.68
5.3.110.0030.05714.48
5.3.100.0070.06014.20
5.3.90.0100.04714.10
5.3.80.0130.04714.17
5.3.70.0030.05714.02
5.3.60.0030.05314.18
5.3.50.0100.04714.02
5.3.40.0070.05013.97
5.3.30.0070.04713.84
5.3.20.0100.04313.67
5.3.10.0070.04713.82
5.3.00.0070.05013.81
5.2.170.0130.03311.30
5.2.160.0030.04311.06
5.2.150.0030.04311.22
5.2.140.0100.03711.27
5.2.130.0070.04011.02
5.2.120.0100.03711.09
5.2.110.0000.04711.02
5.2.100.0030.04011.04
5.2.90.0070.04011.04
5.2.80.0070.04011.06
5.2.70.0100.04011.03
5.2.60.0100.03711.21
5.2.50.0070.04010.89
5.2.40.0030.04310.90
5.2.30.0100.03711.05
5.2.20.0070.04010.87
5.2.10.0030.04011.03
5.2.00.0030.04010.75
5.1.60.0000.03710.00
5.1.50.0000.03710.00
5.1.40.0070.03010.13
5.1.30.0070.03310.26
5.1.20.0000.04010.28
5.1.10.0070.03310.16
5.1.00.0070.03710.11
5.0.50.0000.0338.45
5.0.40.0070.0338.50
5.0.30.0000.0478.11
5.0.20.0030.0308.34
5.0.10.0070.0338.07
5.0.00.0070.0408.25
4.4.90.0000.0235.88
4.4.80.0000.0275.87
4.4.70.0030.0205.85
4.4.60.0000.0235.92
4.4.50.0030.0205.85
4.4.40.0000.0375.88
4.4.30.0000.0235.89
4.4.20.0000.0235.93
4.4.10.0030.0305.84
4.4.00.0000.0435.85
4.3.110.0070.0175.71
4.3.100.0030.0205.68
4.3.90.0070.0175.83
4.3.80.0000.0375.75
4.3.70.0030.0205.82
4.3.60.0070.0135.67
4.3.50.0000.0235.72
4.3.40.0100.0235.72
4.3.30.0000.0234.57
4.3.20.0000.0234.45
4.3.10.0070.0174.38
4.3.00.0100.0236.98

preferences:
55.88 ms | 401 KiB | 5 Q