Search code examples
phpmathechoadditiondivide

Add / Divide Numbers in PHP


I am working on a Facebook App that needs to be able to average three numbers. But, it always return 0 as the answer. Here is my code:

$y = 100;
$n = 250;
$m = 300;
$number = ($y + $n + $m / 3);
echo 'Index: '.$number;

It always displays Index: 0

Any ideas?


Solution

  • $y = 100;
    $n = 250;
    $m = 300;
    $number = ($y + $n + $m) / 3;
    echo 'Index: '.$number;
    

    Also - you missed ; in the end of the first 3 lines