3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function my_sum ($list){ $sum = 0; for ($i = 0; $i <= count($list); $i++){ print($i."<br />"); $sum = $sum + $list[$i]; return $sum; } } $list = array(5,2,3,9); $sum = my_sum($list); print("The sum of all array elements is $sum <br />"); ?>
Output for 4.3.0 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
0<br />The sum of all array elements is 5 <br />