3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function _AVG($args){ /*$count = func_num_args(); $args = func_get_args();*/ $count = count($args); $sum = array_sum($args); return bcdiv($sum,$count,2); } function _AVG1($args){ /*$count = func_num_args(); $args = func_get_args();*/ $count = count($args); //$sum = array_sum($args); return array_sum($args) / $count; } echo _AVG(array(3.17,2.22,2.54)); echo '<br />'; echo _AVG1(array(3.17,2.22,2.54));
Output for 4.3.0 - 7.1.0
2.64<br />2.6433333333333