fork(4) download
  1. <?php
  2.  
  3. $arr = array(2.00, 4.10, 5.00, 1.21);
  4.  
  5. echo calcValues($arr, "+"); // 12.31
  6. echo calcValues($arr, "*"); // 49.61
  7.  
  8. function calcValues($values, $operacao){
  9. if($operacao == "+"){
  10. return array_sum($values);
  11. }
  12. elseif ($operacao == "*"){
  13. return array_product($values);
  14. }
  15. }
Success #stdin #stdout 0.01s 20520KB
stdin
Standard input is empty
stdout
12.3149.61