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,3));

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.0160.00316.63
8.3.50.0090.00618.44
8.3.40.0070.00718.75
8.3.30.0110.00718.85
8.3.20.0000.00818.81
8.3.10.0090.00021.52
8.3.00.0050.00319.26
8.2.180.0230.00316.32
8.2.170.0120.00922.96
8.2.160.0130.00320.39
8.2.150.0050.00324.18
8.2.140.0080.00024.66
8.2.130.0060.00319.64
8.2.120.0040.00426.35
8.2.110.0060.00321.19
8.2.100.0040.00817.97
8.2.90.0040.00417.97
8.2.80.0030.00519.17
8.2.70.0080.00017.49
8.2.60.0030.00517.80
8.2.50.0030.00518.10
8.2.40.0070.00020.59
8.2.30.0050.00219.23
8.2.20.0040.00418.00
8.2.10.0040.00417.93
8.2.00.0030.00617.57
8.1.280.0060.01525.92
8.1.270.0060.00322.14
8.1.260.0050.00326.35
8.1.250.0060.00328.09
8.1.240.0040.00423.95
8.1.230.0080.00320.95
8.1.220.0060.00317.79
8.1.210.0090.00018.77
8.1.200.0000.00917.35
8.1.190.0040.00417.22
8.1.180.0040.00718.10
8.1.170.0040.00418.71
8.1.160.0040.00418.94
8.1.150.0050.00220.19
8.1.140.0000.00719.58
8.1.130.0000.00717.61
8.1.120.0040.00417.50
8.1.110.0000.00817.34
8.1.100.0000.00817.42
8.1.90.0000.00817.49
8.1.80.0000.00717.42
8.1.70.0000.00717.49
8.1.60.0030.00617.41
8.1.50.0050.00317.52
8.1.40.0040.00417.55
8.1.30.0030.00617.62
8.1.20.0030.00517.70
8.1.10.0040.00417.43
8.1.00.0040.00417.49
8.0.300.0000.00820.04
8.0.290.0000.00816.75
8.0.280.0040.00418.44
8.0.270.0000.00817.24
8.0.260.0030.00317.23
8.0.250.0000.00616.84
8.0.240.0040.00416.93
8.0.230.0040.00416.98
8.0.220.0070.00016.90
8.0.210.0030.00316.83
8.0.200.0060.00016.84
8.0.190.0000.00816.95
8.0.180.0000.00716.90
8.0.170.0040.00416.95
8.0.160.0060.00316.90
8.0.150.0070.00016.96
8.0.140.0000.00716.87
8.0.130.0030.00313.25
8.0.120.0000.00916.89
8.0.110.0040.00416.89
8.0.100.0000.00716.88
8.0.90.0000.00816.92
8.0.80.0130.00316.85
8.0.70.0000.00716.71
8.0.60.0000.00716.84
8.0.50.0040.00316.89
8.0.30.0130.00417.06
8.0.20.0090.01117.40
8.0.10.0040.00417.05
8.0.00.0100.01316.79
7.4.330.0000.00615.55
7.4.320.0030.00316.55
7.4.300.0000.00616.50
7.4.290.0030.00316.51
7.4.280.0060.00316.48
7.4.270.0040.00616.52
7.4.260.0030.00316.60
7.4.250.0040.00416.39
7.4.240.0040.00416.51
7.4.230.0000.00716.63
7.4.220.0120.00616.40
7.4.210.0080.00916.61
7.4.200.0030.00316.62
7.4.160.0100.00516.57
7.4.150.0120.00617.40
7.4.140.0090.01317.86
7.4.130.0100.01016.46
7.4.120.0100.00816.50
7.4.110.0000.01716.39
7.4.100.0190.00316.46
7.4.90.0140.00316.50
7.4.80.0070.01019.39
7.4.70.0080.00816.56
7.4.60.0160.00016.37
7.4.50.0030.01416.61
7.4.40.0130.00316.37
7.4.30.0150.00616.57
7.4.00.0100.00715.14
7.3.330.0000.00613.10
7.3.320.0000.00613.29
7.3.310.0030.00316.19
7.3.300.0000.00716.29
7.3.290.0040.00416.27
7.3.280.0070.01116.27
7.3.270.0070.01317.40
7.3.260.0060.01416.37
7.3.250.0130.00416.35
7.3.240.0120.00616.34
7.3.230.0070.01316.57
7.3.210.0090.00916.54
7.3.200.0070.01016.41
7.3.190.0090.00616.39
7.3.180.0060.00916.46
7.3.170.0090.00916.54
7.3.160.0110.00616.38
7.3.10.0070.00716.53
7.3.00.0070.00716.76
7.2.330.0140.00416.39
7.2.320.0060.01216.73
7.2.310.0070.01016.63
7.2.300.0120.00616.63
7.2.290.0060.01016.50
7.2.130.0060.00316.85
7.2.120.0040.00416.88
7.2.110.0030.01016.76
7.2.100.0070.00717.00
7.2.90.0000.00917.02
7.2.80.0080.00817.01
7.2.70.0000.00916.81
7.2.60.0060.00817.01
7.2.50.0070.00417.08
7.2.40.0090.00316.84
7.2.30.0080.00016.95
7.2.20.0030.01316.68
7.2.10.0070.00716.84
7.2.00.0060.00718.07
7.1.250.0030.00615.91
7.1.200.0070.00415.80
7.1.100.0040.00418.04
7.1.70.0050.00217.33
7.1.60.0060.00617.14
7.1.00.0100.07022.36
7.0.200.0260.01015.00
7.0.130.0100.05322.19
7.0.120.0030.06322.06
7.0.110.0200.05022.07
7.0.100.0070.05722.12
7.0.90.0030.06321.99
7.0.80.0070.05721.97
7.0.70.0100.06022.27
7.0.60.0100.05322.07
7.0.50.0030.05722.05
7.0.40.0070.05322.11
7.0.30.0170.04322.11
7.0.20.0070.05321.98
7.0.10.0030.05722.05
7.0.00.0070.05722.08
5.6.270.0030.06020.92
5.6.260.0130.05320.84
5.6.250.0100.05721.06
5.6.240.0070.06020.88
5.6.230.0070.07320.84
5.6.220.0030.06020.95
5.6.210.0070.05320.99
5.6.200.0030.06021.00
5.6.190.0100.05321.00
5.6.180.0100.05021.03
5.6.170.0170.04721.01
5.6.160.0100.05321.09
5.6.150.0030.06020.90
5.6.140.0100.05320.85
5.6.130.0000.06320.83
5.6.120.0100.05721.00
5.6.110.0030.06020.93
5.6.100.0070.05720.96
5.6.90.0070.05321.07
5.6.80.0000.06020.22
5.6.70.0070.05020.38
5.6.60.0100.05020.44
5.6.50.0130.04720.31
5.6.40.0070.05020.20
5.6.30.0070.05320.40
5.6.20.0070.05720.21
5.6.10.0030.05320.30
5.6.00.0070.05020.45

preferences:
58.38 ms | 401 KiB | 5 Q