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); } } else{ echo count(array_column($this->catTree, 'parent', $parent)); if(count(array_column($this->catTree, 'parent', $parent)) < 1){ echo 'Parent not found'; } 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('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.0040.01118.42
8.3.50.0130.00721.19
8.3.40.0060.01018.85
8.3.30.0040.01119.09
8.3.20.0080.00020.16
8.3.10.0080.00023.53
8.3.00.0050.00319.31
8.2.180.0180.00318.16
8.2.170.0030.01022.96
8.2.160.0100.00320.39
8.2.150.0140.00424.18
8.2.140.0030.00624.66
8.2.130.0070.00026.16
8.2.120.0050.00319.36
8.2.110.0040.00422.22
8.2.100.0100.00318.22
8.2.90.0030.00719.14
8.2.80.0000.00817.97
8.2.70.0050.00317.61
8.2.60.0040.00417.80
8.2.50.0030.00718.07
8.2.40.0050.00319.95
8.2.30.0040.00418.20
8.2.20.0000.00817.80
8.2.10.0040.00418.05
8.2.00.0040.00418.12
8.1.280.0190.00025.92
8.1.270.0090.00020.38
8.1.260.0080.00026.35
8.1.250.0040.00428.09
8.1.240.0060.00323.70
8.1.230.0080.00319.11
8.1.220.0040.00417.79
8.1.210.0000.00818.77
8.1.200.0030.00717.35
8.1.190.0060.00317.23
8.1.180.0000.00718.10
8.1.170.0040.00418.66
8.1.160.0040.00422.14
8.1.150.0080.00018.93
8.1.140.0040.00717.48
8.1.130.0070.00017.84
8.1.120.0050.00317.47
8.1.110.0000.00717.43
8.1.100.0050.00317.38
8.1.90.0090.00017.46
8.1.80.0000.00717.53
8.1.70.0030.00517.38
8.1.60.0090.00017.62
8.1.50.0030.00717.45
8.1.40.0050.00317.41
8.1.30.0030.00517.56
8.1.20.0080.00017.58
8.1.10.0000.00917.46
8.1.00.0040.00417.55
8.0.300.0050.00318.77
8.0.290.0000.00716.75
8.0.280.0000.00718.32
8.0.270.0000.00717.27
8.0.260.0070.00017.27
8.0.250.0030.00316.93
8.0.240.0000.00816.98
8.0.230.0000.00716.86
8.0.220.0040.00416.90
8.0.210.0070.00016.92
8.0.200.0030.00316.99
8.0.190.0080.00017.00
8.0.180.0070.00016.86
8.0.170.0000.00816.94
8.0.160.0050.00316.92
8.0.150.0030.00316.80
8.0.140.0040.00416.82
8.0.130.0030.00613.35
8.0.120.0040.00416.88
8.0.110.0070.00016.91
8.0.100.0030.00516.77
8.0.90.0060.00616.86
8.0.80.0070.01116.92
8.0.70.0050.00216.80
8.0.60.0080.00016.76
8.0.50.0030.00516.96
8.0.30.0100.01317.27
8.0.20.0150.00617.40
8.0.10.0000.00716.86
8.0.00.0120.00816.74
7.4.330.0000.00515.09
7.4.320.0000.00716.50
7.4.300.0000.00716.41
7.4.290.0000.00716.47
7.4.280.0000.00716.48
7.4.270.0000.00716.47
7.4.260.0040.00416.60
7.4.250.0070.00016.38
7.4.240.0060.00116.49
7.4.230.0000.00716.36
7.4.220.0160.00316.57
7.4.210.0150.00616.52
7.4.200.0000.00716.36
7.4.160.0030.01316.60
7.4.150.0120.00517.40
7.4.140.0130.00817.86
7.4.130.0200.00416.52
7.4.120.0120.00716.61
7.4.110.0110.00616.47
7.4.100.0100.01316.43
7.4.90.0070.01016.64
7.4.80.0110.00719.39
7.4.70.0110.01016.53
7.4.60.0070.01116.48
7.4.50.0000.00716.37
7.4.40.0090.01316.42
7.4.30.0120.00616.63
7.4.00.0080.00815.00
7.3.330.0000.00813.45
7.3.320.0030.00313.45
7.3.310.0050.00216.19
7.3.300.0040.00416.43
7.3.290.0050.01016.36
7.3.280.0060.01416.38
7.3.270.0150.00317.40
7.3.260.0140.00316.46
7.3.250.0100.00716.50
7.3.240.0120.01216.46
7.3.230.0150.00416.60
7.3.210.0030.01316.32
7.3.200.0080.00819.39
7.3.190.0130.00416.49
7.3.180.0060.00916.36
7.3.170.0100.00616.45
7.3.160.0140.00316.46
7.3.120.0100.00715.15
7.3.110.0070.00714.77
7.3.100.0030.01314.86
7.3.90.0110.00314.77
7.3.80.0110.00314.98
7.3.70.0060.00615.02
7.3.60.0070.00714.84
7.3.50.0120.00614.89
7.3.40.0030.00614.91
7.3.30.0090.00614.93
7.3.20.0070.00716.50
7.3.10.0070.01116.68
7.3.00.0100.00516.64
7.2.330.0110.00716.76
7.2.320.0080.00916.84
7.2.310.0000.01616.73
7.2.300.0130.01016.78
7.2.290.0120.01216.85
7.2.250.0100.00715.11
7.2.240.0090.00914.78
7.2.230.0030.01515.34
7.2.220.0030.00915.05
7.2.210.0000.01615.26
7.2.200.0030.01015.23
7.2.190.0140.00315.18
7.2.180.0090.00914.96
7.2.170.0120.00015.12
7.2.130.0070.01017.03
7.2.120.0070.00716.95
7.2.110.0000.01116.92
7.2.100.0140.00616.89
7.2.90.0120.00316.85
7.2.80.0060.01016.68
7.2.70.0070.00316.91
7.2.60.0080.00616.97
7.2.50.0030.00716.63
7.2.40.0070.01017.09
7.2.30.0090.00617.08
7.2.20.0090.00916.99
7.2.10.0110.00416.99
7.2.00.0070.01018.20
7.1.330.0110.00315.88
7.1.320.0000.01516.00
7.1.310.0080.00815.93
7.1.300.0070.00715.98
7.1.290.0030.00915.85
7.1.280.0030.00715.84
7.1.270.0070.00715.73
7.1.260.0070.00715.75
7.1.250.0070.00715.84
7.1.200.0070.00315.49
7.1.100.0030.00918.12
7.1.70.0090.00616.89
7.1.60.0070.01819.86
7.1.50.0140.01116.98
7.1.00.0030.07722.57
7.0.200.0090.00615.05
7.0.60.0070.08719.89
7.0.50.0070.08317.87
7.0.40.0130.08720.12
7.0.30.0230.03720.16
7.0.20.0300.08020.14
7.0.10.0130.03320.22
7.0.00.0070.07020.38
5.6.280.0030.07020.92
5.6.210.0030.06720.72
5.6.200.0070.07318.25
5.6.190.0030.08020.41
5.6.180.0570.05020.57
5.6.170.0200.04020.55
5.6.160.0030.08320.45
5.6.150.0030.04018.18
5.6.140.0030.08318.15
5.6.130.0030.09018.14
5.6.120.0100.08321.00
5.6.110.0030.04021.09
5.6.100.0100.06321.05
5.6.90.0030.06721.00
5.6.80.0170.06320.40
5.5.350.0300.06020.32
5.5.340.0030.08318.02
5.5.330.0100.05320.29
5.5.320.0200.04320.35
5.5.310.0370.05720.35
5.5.300.0100.07717.95
5.5.290.0030.09018.04
5.5.280.0130.08320.79
5.5.270.0000.04320.94
5.5.260.0130.06020.77
5.5.250.0100.07020.67
5.5.240.0170.06720.38
5.4.450.0400.06019.48
5.4.440.0570.06319.64
5.4.430.0000.06019.38
5.4.420.0070.05319.42
5.4.410.0130.05019.28
5.4.400.0100.05019.12
5.4.390.0000.05719.07
5.4.380.0200.05019.07
5.4.370.0130.04719.15
5.4.360.0070.05319.12
5.4.350.0130.04719.09
5.4.340.0070.05019.05
5.4.320.0100.05019.08
5.4.310.0100.05319.02
5.4.300.0200.05319.16
5.4.290.0170.04319.16
5.4.280.0100.05019.08
5.4.270.0030.05319.04
5.4.260.0030.05319.23
5.4.250.0030.05719.12
5.4.240.0030.05719.01
5.4.230.0100.04719.20
5.4.220.0170.04719.03
5.4.210.0170.04019.25
5.4.200.0070.05017.02
5.4.190.0070.05319.19
5.4.180.0030.05719.11
5.4.170.0130.06319.19
5.4.160.0030.05319.11
5.4.150.0070.05719.14
5.4.140.0130.05716.68
5.4.130.0130.04016.64
5.4.120.0000.05316.71
5.4.110.0070.05716.29
5.4.100.0070.05016.52
5.4.90.0130.04316.46
5.4.80.0030.05016.29
5.4.70.0030.06716.34
5.4.60.0030.07016.23
5.4.50.0030.05316.43
5.4.40.0130.04316.23
5.4.30.0130.04716.23
5.4.20.0070.05016.50
5.4.10.0030.05016.38
5.4.00.0130.04016.03
5.3.290.0100.05014.69
5.3.280.0000.06014.64
5.3.270.0000.06014.77
5.3.260.0170.04314.63
5.3.250.0070.05014.77
5.3.240.0070.05014.52
5.3.230.0070.06014.78
5.3.220.0070.05014.75
5.3.210.0070.05314.59
5.3.200.0100.04314.57
5.3.190.0130.04314.65
5.3.180.0070.05014.64
5.3.170.0070.05014.54
5.3.160.0070.05014.51
5.3.150.0070.05314.64
5.3.140.0030.05314.58
5.3.130.0000.06714.57
5.3.120.0070.06014.52
5.3.110.0100.05014.63
5.3.100.0170.04314.12
5.3.90.0100.04713.89
5.3.80.0070.05013.95
5.3.70.0070.05013.89
5.3.60.0130.04314.18
5.3.50.0000.05713.95
5.3.40.0070.06014.08
5.3.30.0130.04314.07
5.3.20.0070.04713.66
5.3.10.0070.04713.61
5.3.00.0100.04713.57
5.2.170.0100.03711.09
5.2.160.0000.04311.14
5.2.150.0030.04311.14
5.2.140.0030.04311.31
5.2.130.0100.04011.02
5.2.120.0030.04010.96
5.2.110.0000.04311.09
5.2.100.0030.04011.12
5.2.90.0070.04011.12
5.2.80.0070.05311.18
5.2.70.0070.04011.18
5.2.60.0100.03711.22
5.2.50.0070.03711.19
5.2.40.0070.04010.93
5.2.30.0030.04310.83
5.2.20.0100.03310.89
5.2.10.0100.03310.86
5.2.00.0100.03310.68
5.1.60.0000.0379.90
5.1.50.0100.0309.91
5.1.40.0030.0339.88
5.1.30.0030.03310.26
5.1.20.0030.04710.32
5.1.10.0030.03710.24
5.1.00.0000.0409.93
5.0.50.0030.0278.50
5.0.40.0000.0308.57
5.0.30.0030.0438.13
5.0.20.0030.0278.11
5.0.10.0030.0278.33
5.0.00.0030.0478.03
4.4.90.0070.0175.88
4.4.80.0070.0175.74
4.4.70.0030.0205.87
4.4.60.0070.0175.75
4.4.50.0000.0235.75
4.4.40.0030.0335.82
4.4.30.0030.0205.73
4.4.20.0000.0235.91
4.4.10.0000.0235.82
4.4.00.0030.0335.79
4.3.110.0000.0235.86
4.3.100.0070.0175.83
4.3.90.0030.0205.76
4.3.80.0070.0335.66
4.3.70.0030.0235.76
4.3.60.0070.0175.75
4.3.50.0000.0235.78
4.3.40.0030.0335.61
4.3.30.0000.0234.60
4.3.20.0000.0234.53
4.3.10.0000.0234.46
4.3.00.0130.0177.01

preferences:
57.86 ms | 401 KiB | 5 Q