3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $arr = [ [1, 2, 3], [4, 5, 6], [7, 8, 9], ]; $sum = 0; $av = 0; for($i = 0 ; $i < count($arr); $i++){ for ($j = 0; $j < count($arr[$i]); $j++){ $sum += $arr[$i][$j]; $av = count($arr[$i][$j]); } } echo 'Сборът на масива е: ' . $sum . PHP_EOL . 'Средноаритметичната стойност е: ' . ($sum / $av);
based on RkMA0
Output for 7.2.0
Warning: count(): Parameter must be an array or an object that implements Countable in /in/0rnc1 on line 15 Warning: count(): Parameter must be an array or an object that implements Countable in /in/0rnc1 on line 15 Warning: count(): Parameter must be an array or an object that implements Countable in /in/0rnc1 on line 15 Warning: count(): Parameter must be an array or an object that implements Countable in /in/0rnc1 on line 15 Warning: count(): Parameter must be an array or an object that implements Countable in /in/0rnc1 on line 15 Warning: count(): Parameter must be an array or an object that implements Countable in /in/0rnc1 on line 15 Warning: count(): Parameter must be an array or an object that implements Countable in /in/0rnc1 on line 15 Warning: count(): Parameter must be an array or an object that implements Countable in /in/0rnc1 on line 15 Warning: count(): Parameter must be an array or an object that implements Countable in /in/0rnc1 on line 15 Сборът на масива е: 45 Средноаритметичната стойност е: 45
Output for 5.4.9 - 7.1.10
Сборът на масива е: 45 Средноаритметичната стойност е: 45
Output for 5.3.19 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/0rnc1 on line 3
Process exited with code 255.