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, 'parent'), $parent); } 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('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.60.0090.00618.43
8.3.50.0070.00921.26
8.3.40.0140.00718.95
8.3.30.0070.00719.27
8.3.20.0080.00020.15
8.3.10.0070.00723.61
8.3.00.0060.00319.81
8.2.180.0120.00318.63
8.2.170.0120.00318.89
8.2.160.0160.00322.96
8.2.150.0080.00024.18
8.2.140.0090.00024.66
8.2.130.0040.01126.16
8.2.120.0000.00819.48
8.2.110.0090.00322.20
8.2.100.0080.00418.16
8.2.90.0060.00319.17
8.2.80.0060.00317.97
8.2.70.0000.00917.63
8.2.60.0030.00517.92
8.2.50.0040.00418.07
8.2.40.0000.01019.89
8.2.30.0040.00418.04
8.2.20.0030.00517.72
8.2.10.0040.00418.07
8.2.00.0040.00418.07
8.1.280.0140.00025.92
8.1.270.0050.00320.22
8.1.260.0120.00626.35
8.1.250.0100.00728.09
8.1.240.0030.00622.48
8.1.230.0070.00419.15
8.1.220.0060.00317.74
8.1.210.0040.00418.77
8.1.200.0060.00317.25
8.1.190.0060.00317.36
8.1.180.0000.00818.10
8.1.170.0080.00018.36
8.1.160.0070.00022.08
8.1.150.0000.00718.82
8.1.140.0070.00217.44
8.1.130.0030.00317.89
8.1.120.0000.00817.38
8.1.110.0040.00417.48
8.1.100.0040.00417.52
8.1.90.0080.00017.39
8.1.80.0030.00317.31
8.1.70.0000.00717.51
8.1.60.0050.00317.55
8.1.50.0040.00717.55
8.1.40.0050.00317.55
8.1.30.0050.00317.65
8.1.20.0080.00017.67
8.1.10.0000.00717.61
8.1.00.0020.00517.52
8.0.300.0000.00718.77
8.0.290.0000.00716.63
8.0.280.0000.00818.41
8.0.270.0030.00317.14
8.0.260.0030.00317.22
8.0.250.0030.00316.98
8.0.240.0070.00016.98
8.0.230.0040.00416.85
8.0.220.0030.00316.91
8.0.210.0070.00016.88
8.0.200.0030.00316.83
8.0.190.0040.00416.88
8.0.180.0040.00416.96
8.0.170.0040.00416.93
8.0.160.0060.00316.83
8.0.150.0040.00416.85
8.0.140.0030.00516.86
8.0.130.0090.00013.32
8.0.120.0030.00616.86
8.0.110.0000.00816.90
8.0.100.0000.00816.81
8.0.90.0000.00816.84
8.0.80.0000.02116.85
8.0.70.0050.00316.89
8.0.60.0050.00216.93
8.0.50.0000.00716.86
8.0.30.0080.01417.12
8.0.20.0140.00717.40
8.0.10.0070.00017.03
8.0.00.0100.01016.88
7.4.330.0000.00515.03
7.4.320.0000.00616.52
7.4.300.0000.00616.61
7.4.290.0040.00416.42
7.4.280.0030.00316.61
7.4.270.0030.00316.59
7.4.260.0050.00216.61
7.4.250.0050.00216.56
7.4.240.0030.00416.51
7.4.230.0030.00316.71
7.4.220.0060.01616.58
7.4.210.0060.01516.57
7.4.200.0070.00016.64
7.4.160.0040.01116.36
7.4.150.0120.00617.40
7.4.140.0150.00817.86
7.4.130.0100.00716.55
7.4.120.0110.01016.46
7.4.110.0100.00716.70
7.4.100.0150.00916.57
7.4.90.0110.00616.46
7.4.80.0100.00919.39
7.4.70.0060.01216.63
7.4.60.0100.00716.51
7.4.50.0030.00316.36
7.4.40.0120.00616.43
7.4.30.0130.00916.57
7.4.00.0050.01214.85
7.3.330.0000.00613.20
7.3.320.0030.00313.20
7.3.310.0030.00316.27
7.3.300.0030.00316.38
7.3.290.0070.00716.34
7.3.280.0050.01116.42
7.3.270.0090.00917.40
7.3.260.0150.00616.44
7.3.250.0090.00816.41
7.3.240.0060.01616.38
7.3.230.0090.00916.66
7.3.210.0080.00816.65
7.3.200.0070.01719.39
7.3.190.0070.00716.26
7.3.180.0060.01616.54
7.3.170.0090.01216.27
7.3.160.0060.01216.57
7.3.120.0050.01114.85
7.3.110.0050.01214.85
7.3.100.0070.01014.81
7.3.90.0050.00514.91
7.3.80.0080.00814.74
7.3.70.0090.00714.91
7.3.60.0070.00514.91
7.3.50.0060.00714.52
7.3.40.0090.00314.81
7.3.30.0090.00414.85
7.3.20.0040.00816.72
7.3.10.0040.00916.54
7.3.00.0080.00316.69
7.2.330.0100.00716.70
7.2.320.0140.00416.91
7.2.310.0090.00916.74
7.2.300.0110.01116.57
7.2.290.0040.01416.50
7.2.250.0090.00915.10
7.2.240.0070.01115.10
7.2.230.0060.01015.23
7.2.220.0050.00514.97
7.2.210.0020.01215.13
7.2.200.0030.00915.05
7.2.190.0050.00915.27
7.2.180.0000.01415.12
7.2.170.0040.00915.17
7.2.160.0110.00715.00
7.2.150.0030.01316.91
7.2.140.0120.00016.95
7.2.130.0030.00816.88
7.2.120.0040.01116.96
7.2.110.0060.01116.86
7.2.100.0120.00016.68
7.2.90.0070.00717.05
7.2.80.0070.01017.09
7.2.70.0000.01216.97
7.2.60.0060.00916.70
7.2.50.0030.01016.79
7.2.40.0040.01116.99
7.2.30.0040.01117.14
7.2.20.0030.01417.00
7.2.10.0030.01317.03
7.2.00.0050.00718.14
7.1.330.0080.00615.81
7.1.320.0040.00915.80
7.1.310.0060.00815.81
7.1.300.0020.00915.65
7.1.290.0050.01015.81
7.1.280.0080.00815.96
7.1.270.0050.00915.85
7.1.260.0030.00815.89
7.1.250.0000.01115.73
7.1.100.0040.00718.24
7.1.70.0030.00517.16
7.1.60.0140.01019.86
7.1.50.0130.01016.77
7.1.00.0000.08022.43
7.0.200.0050.00514.98
7.0.60.0100.03719.90
7.0.50.0000.05717.90
7.0.40.0030.05020.11
7.0.30.0200.04020.21
7.0.20.0300.04720.25
7.0.10.0000.09020.22
7.0.00.0200.07320.11
5.6.280.0070.06721.03
5.6.210.0030.05020.78
5.6.200.0030.08318.19
5.6.190.0070.04720.49
5.6.180.0470.05020.61
5.6.170.0330.07320.48
5.6.160.0170.07320.54
5.6.150.0070.05018.13
5.6.140.0030.04018.16
5.6.130.0030.08318.23
5.6.120.0030.09021.03
5.6.110.0070.09020.98
5.6.100.0070.08321.10
5.6.90.0100.04321.14
5.6.80.0130.07320.36
5.5.350.0300.07020.42
5.5.340.0030.05717.96
5.5.330.0070.04720.29
5.5.320.0300.07320.30
5.5.310.0370.07020.30
5.5.300.0100.08018.08
5.5.290.0070.08317.97
5.5.280.0070.03720.82
5.5.270.0070.04020.77
5.5.260.0100.07020.79
5.5.250.0230.06720.63
5.5.240.0030.08020.05
5.4.450.0870.06319.61
5.4.440.0500.06319.21
5.4.430.0070.05719.43
5.4.420.0170.04319.51
5.4.410.0000.06019.52
5.4.400.0130.04319.10
5.4.390.0130.05319.21
5.4.380.0070.05319.09
5.4.370.0100.05019.04
5.4.360.0130.06019.13
5.4.350.0170.04719.16
5.4.340.0070.05719.07
5.4.320.0100.05319.07
5.4.310.0130.04719.13
5.4.300.0000.06019.13
5.4.290.0130.04319.07
5.4.280.0100.05019.11
5.4.270.0070.05319.25
5.4.260.0070.05319.05
5.4.250.0070.05319.10
5.4.240.0000.06019.06
5.4.230.0100.04718.97
5.4.220.0130.05018.97
5.4.210.0100.05019.14
5.4.200.0100.04716.70
5.4.190.0070.05019.14
5.4.180.0130.04719.22
5.4.170.0100.05019.11
5.4.160.0000.05718.96
5.4.150.0100.05019.10
5.4.140.0130.04316.46
5.4.130.0130.04016.35
5.4.120.0130.04316.33
5.4.110.0000.05316.53
5.4.100.0030.07316.59
5.4.90.0170.05316.34
5.4.80.0100.05016.61
5.4.70.0100.04716.30
5.4.60.0170.04016.59
5.4.50.0030.05016.22
5.4.40.0170.04016.55
5.4.30.0070.04716.28
5.4.20.0070.05016.43
5.4.10.0070.05316.50
5.4.00.0100.04716.03
5.3.290.0030.05714.59
5.3.280.0030.05714.67
5.3.270.0070.05314.68
5.3.260.0070.05714.67
5.3.250.0100.05014.47
5.3.240.0000.05714.53
5.3.230.0070.05314.62
5.3.220.0100.04714.61
5.3.210.0070.06014.51
5.3.200.0100.04714.59
5.3.190.0100.05014.49
5.3.180.0100.04714.58
5.3.170.0100.04714.64
5.3.160.0030.05314.71
5.3.150.0030.05314.73
5.3.140.0000.06714.47
5.3.130.0070.05714.56
5.3.120.0030.05714.43
5.3.110.0030.05714.67
5.3.100.0000.05714.06
5.3.90.0070.05014.08
5.3.80.0100.04713.88
5.3.70.0100.04713.95
5.3.60.0070.05313.98
5.3.50.0000.05713.97
5.3.40.0100.04713.99
5.3.30.0030.05013.88
5.3.20.0070.04713.56
5.3.10.0070.04713.73
5.3.00.0070.05013.63
5.2.170.0030.04311.07
5.2.160.0070.03711.00
5.2.150.0100.03711.11
5.2.140.0100.03711.07
5.2.130.0100.03710.96
5.2.120.0030.04010.96
5.2.110.0100.04311.01
5.2.100.0070.03711.12
5.2.90.0070.03710.96
5.2.80.0030.04311.09
5.2.70.0100.03711.04
5.2.60.0100.03710.96
5.2.50.0000.04710.93
5.2.40.0030.04010.94
5.2.30.0070.04711.13
5.2.20.0100.03310.95
5.2.10.0100.03310.85
5.2.00.0100.03310.87
5.1.60.0030.03310.14
5.1.50.0070.03310.05
5.1.40.0000.0379.88
5.1.30.0070.04010.41
5.1.20.0030.04310.50
5.1.10.0030.03710.01
5.1.00.0070.03310.23
5.0.50.0100.0238.45
5.0.40.0030.0338.42
5.0.30.0000.0478.27
5.0.20.0100.0208.21
5.0.10.0070.0238.23
5.0.00.0070.0438.25
4.4.90.0000.0275.76
4.4.80.0000.0275.77
4.4.70.0030.0205.87
4.4.60.0000.0235.90
4.4.50.0000.0235.89
4.4.40.0030.0335.87
4.4.30.0030.0205.74
4.4.20.0000.0235.93
4.4.10.0070.0175.80
4.4.00.0000.0375.97
4.3.110.0000.0235.69
4.3.100.0070.0175.70
4.3.90.0030.0205.79
4.3.80.0000.0335.78
4.3.70.0000.0205.83
4.3.60.0000.0205.64
4.3.50.0000.0275.65
4.3.40.0070.0305.74
4.3.30.0000.0234.55
4.3.20.0100.0134.48
4.3.10.0000.0234.53
4.3.00.0070.0236.98

preferences:
53.02 ms | 401 KiB | 5 Q