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; } $avg = _AVG(array(3.17,2.22,2.54)); $addmtg = bcadd($avg,3.17,2); $mul95 = bcmul($addmtg,0.95,2); $div2 = bcdiv($mul95,2,2); echo $div2;
Output for 4.3.0 - 5.4.45, 5.5.35, 5.6.21 - 5.6.28, 7.0.6 - 7.1.0
2.75
Output for 7.0.0 - 7.0.5
Fatal error: Uncaught Error: Call to undefined function bcdiv() in /in/BHvBr:7 Stack trace: #0 /in/BHvBr(16): _AVG(Array) #1 {main} thrown in /in/BHvBr on line 7
Process exited with code 255.
Output for 5.5.0 - 5.5.34, 5.6.0 - 5.6.20
Fatal error: Call to undefined function bcdiv() in /in/BHvBr on line 7
Process exited with code 255.