<?php
$arr = array(2.00, 4.10, 5.00, 1.21);
echo calcValues($arr, "+"); // 12.31
echo calcValues($arr, "*"); // 49.61
function calcValues($values, $operacao){
if($operacao == "+"){
}
elseif ($operacao == "*"){
}
}
PD9waHAKCiRhcnIgPSBhcnJheSgyLjAwLCA0LjEwLCA1LjAwLCAxLjIxKTsKCmVjaG8gY2FsY1ZhbHVlcygkYXJyLCAiKyIpOyAvLyAxMi4zMQplY2hvIGNhbGNWYWx1ZXMoJGFyciwgIioiKTsgLy8gNDkuNjEKCmZ1bmN0aW9uIGNhbGNWYWx1ZXMoJHZhbHVlcywgJG9wZXJhY2FvKXsgICAKICAgIGlmKCRvcGVyYWNhbyA9PSAiKyIpewogICAgICAgIHJldHVybiBhcnJheV9zdW0oJHZhbHVlcyk7CiAgICB9CiAgICBlbHNlaWYgKCRvcGVyYWNhbyA9PSAiKiIpewogICAgICAgIHJldHVybiBhcnJheV9wcm9kdWN0KCR2YWx1ZXMpOwogICAgfQp9