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 $arr[$i][$j], PHP_EOL; echo 'Сборът на масива е: ' . $sum . PHP_EOL . 'Средноаритметичната стойност е: ' . ($sum / $av);
based on UJLlq
Output for 7.2.0
Warning: count(): Parameter must be an array or an object that implements Countable in /in/RkMA0 on line 15 Warning: count(): Parameter must be an array or an object that implements Countable in /in/RkMA0 on line 15 Warning: count(): Parameter must be an array or an object that implements Countable in /in/RkMA0 on line 15 Warning: count(): Parameter must be an array or an object that implements Countable in /in/RkMA0 on line 15 Warning: count(): Parameter must be an array or an object that implements Countable in /in/RkMA0 on line 15 Warning: count(): Parameter must be an array or an object that implements Countable in /in/RkMA0 on line 15 Warning: count(): Parameter must be an array or an object that implements Countable in /in/RkMA0 on line 15 Warning: count(): Parameter must be an array or an object that implements Countable in /in/RkMA0 on line 15 Warning: count(): Parameter must be an array or an object that implements Countable in /in/RkMA0 on line 15 Notice: Undefined offset: 3 in /in/RkMA0 on line 19 Сборът на масива е: 45 Средноаритметичната стойност е: 45
Output for 5.4.9 - 7.1.10
Notice: Undefined offset: 3 in /in/RkMA0 on line 19 Сборът на масива е: 45 Средноаритметичната стойност е: 45
Output for 5.3.19 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/RkMA0 on line 3
Process exited with code 255.