3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = [ [1,2,3 => [4, 5, 6, 7=>[8]]], [1,2,3 => [4, 5, 6, 7=>[8, 9]]] ]; function recursive_count($array, $max_depth=12) { static $stack_depth = 0; $total = 0; foreach($array as $val) { if (is_array($val)) { $stack_depth++; if($max_depth < $stack_depth) { $stack_depth = 0; throw new Exception("Stack level too deep! Stack Limit: $max_depth"); } $total += recursive_count($val, $max_depth); } else { $total++; } } $stack_depth--; return $total; } var_dump(recursive_count($array,2));

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.00716.88
8.3.50.0100.01222.11
8.3.40.0090.00618.74
8.3.30.0040.01418.88
8.3.20.0040.00418.85
8.3.10.0050.00321.85
8.3.00.0040.00419.51
8.2.180.0130.01016.75
8.2.170.0080.00822.96
8.2.160.0160.00420.58
8.2.150.0060.00324.18
8.2.140.0080.00024.66
8.2.130.0030.00626.16
8.2.120.0080.00020.93
8.2.110.0030.00621.99
8.2.100.0040.00717.89
8.2.90.0040.00419.05
8.2.80.0050.00317.97
8.2.70.0000.00818.03
8.2.60.0040.00418.05
8.2.50.0000.00818.10
8.2.40.0060.00319.34
8.2.30.0000.00719.25
8.2.20.0050.00217.99
8.2.10.0050.00218.00
8.2.00.0000.01017.81
8.1.280.0120.00625.92
8.1.270.0040.00422.18
8.1.260.0000.00826.35
8.1.250.0040.00428.09
8.1.240.0060.00319.08
8.1.230.0040.00819.08
8.1.220.0080.00017.78
8.1.210.0080.00018.77
8.1.200.0090.00017.35
8.1.190.0000.00817.35
8.1.180.0000.00818.10
8.1.170.0030.00518.62
8.1.160.0040.00418.88
8.1.150.0000.00720.21
8.1.140.0000.00719.54
8.1.130.0080.00017.70
8.1.120.0100.00017.54
8.1.110.0000.00717.36
8.1.100.0040.00417.48
8.1.90.0040.00417.43
8.1.80.0040.00417.45
8.1.70.0000.00717.45
8.1.60.0000.00817.61
8.1.50.0080.00017.43
8.1.40.0040.00417.53
8.1.30.0030.00517.69
8.1.20.0040.00417.63
8.1.10.0000.00717.59
8.1.00.0080.00017.56
8.0.300.0080.00018.77
8.0.290.0080.00016.63
8.0.280.0030.00318.45
8.0.270.0000.00717.26
8.0.260.0040.00417.33
8.0.250.0000.00717.04
8.0.240.0030.00317.02
8.0.230.0000.00717.07
8.0.220.0030.00317.02
8.0.210.0070.00016.84
8.0.200.0000.00717.02
8.0.190.0000.00817.04
8.0.180.0020.00516.90
8.0.170.0040.00416.97
8.0.160.0050.00216.85
8.0.150.0070.00016.79
8.0.140.0050.00216.93
8.0.130.0050.00013.37
8.0.120.0070.00016.90
8.0.110.0070.00016.96
8.0.100.0040.00416.74
8.0.90.0040.00416.79
8.0.80.0020.01517.02
8.0.70.0040.00416.80
8.0.60.0060.00316.87
8.0.50.0040.00416.85
8.0.30.0120.00617.12
8.0.20.0100.01117.40
8.0.10.0000.00817.06
8.0.00.0110.00716.77
7.4.330.0040.00415.55
7.4.320.0000.00716.59
7.4.300.0070.00016.52
7.4.290.0070.00016.50
7.4.280.0000.00816.64
7.4.270.0080.00016.60
7.4.260.0000.00716.58
7.4.250.0090.00016.57
7.4.240.0030.00316.55
7.4.230.0030.00316.63
7.4.220.0020.00516.61
7.4.210.0130.00316.63
7.4.200.0000.00716.36
7.4.160.0110.00416.60
7.4.150.0130.01317.40
7.4.140.0110.01017.86
7.4.130.0070.01016.52
7.4.120.0110.00716.60
7.4.110.0120.00616.61
7.4.100.0120.00616.46
7.4.90.0100.00716.41
7.4.80.0080.00819.39
7.4.70.0110.00616.45
7.4.60.0110.00516.58
7.4.50.0130.00016.54
7.4.40.0030.01316.53
7.4.30.0130.00316.64
7.4.00.0060.00814.87
7.3.330.0050.00013.37
7.3.320.0000.00613.28
7.3.310.0030.00316.40
7.3.300.0030.00316.42
7.3.290.0000.00716.43
7.3.280.0080.01216.41
7.3.270.0160.00017.40
7.3.260.0090.01216.46
7.3.250.0110.00716.36
7.3.240.0070.01016.41
7.3.230.0030.01516.47
7.3.210.0120.00416.66
7.3.200.0120.00616.44
7.3.190.0060.00916.42
7.3.180.0170.00616.55
7.3.170.0100.00516.66
7.3.160.0070.01116.44
7.3.120.0090.00914.79
7.3.110.0040.01414.69
7.3.100.0000.00914.79
7.3.90.0090.00614.85
7.3.80.0060.00614.72
7.3.70.0040.00414.85
7.3.60.0030.01014.75
7.3.50.0090.00615.00
7.3.40.0070.00714.59
7.3.30.0000.01214.73
7.3.20.0140.00416.71
7.3.10.0080.00816.75
7.3.00.0120.00616.80
7.2.330.0090.00916.43
7.2.320.0100.00716.70
7.2.310.0180.00616.49
7.2.300.0120.00416.51
7.2.290.0130.00316.47
7.2.250.0070.01015.19
7.2.240.0000.02115.11
7.2.230.0070.00715.27
7.2.220.0100.00314.93
7.2.210.0100.00715.07
7.2.200.0060.00814.96
7.2.190.0030.00715.06
7.2.180.0130.00015.11
7.2.170.0050.00514.81
7.2.60.0090.00616.49
7.2.00.0000.01119.03
7.1.330.0030.01015.88
7.1.320.0030.00915.60
7.1.310.0070.00415.77
7.1.300.0030.00915.78
7.1.290.0060.00615.98
7.1.280.0070.00715.43
7.1.270.0040.01215.82
7.1.260.0040.01116.02
7.1.200.0100.00315.51
7.1.100.0030.00918.10
7.1.70.0040.00417.09
7.1.60.0070.00317.14
7.1.50.0090.01217.02
7.1.00.0070.07022.35
7.0.200.0280.00614.86
7.0.130.0030.05722.01
7.0.120.0070.05322.02
7.0.110.0100.05322.11
7.0.100.0170.05321.96
7.0.90.0170.05722.12
7.0.80.0100.05022.10
7.0.70.0070.05722.07
7.0.60.0070.06021.94
7.0.50.0170.06322.21
7.0.40.0030.05722.21
7.0.30.0070.05722.05
7.0.20.0070.05322.14
7.0.10.0070.05322.12
7.0.00.0100.05022.02
5.6.270.0100.05320.89
5.6.260.0070.05321.13
5.6.250.0000.06321.11
5.6.240.0070.05720.89
5.6.230.0230.04020.88
5.6.220.0000.06020.86
5.6.210.0100.05720.97
5.6.200.0070.06320.82
5.6.190.0100.05321.01
5.6.180.0130.05320.86
5.6.170.0070.05721.01
5.6.160.0070.05321.02
5.6.150.0130.05020.95
5.6.140.0000.06320.83
5.6.130.0070.05320.75
5.6.120.0100.05320.85
5.6.110.0100.05321.00
5.6.100.0070.05721.03
5.6.90.0100.05020.84
5.6.80.0130.04320.22
5.6.70.0000.05720.38
5.6.60.0130.04720.39
5.6.50.0100.04720.22
5.6.40.0030.05320.36
5.6.30.0130.04720.37
5.6.20.0070.05320.36
5.6.10.0030.05720.39
5.6.00.0170.04320.18

preferences:
62.62 ms | 401 KiB | 5 Q