3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function my_sum ($list){ $list_length = count($list); $sum = 0; for ($i = 0; $i < $list_length; $i++){ $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
The sum of all array elements is 19 <br />