Add / Divide Numbers in PHP

Zac Brown picture Zac Brown · Nov 3, 2010 · Viewed 30.1k times · Source

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?

Answer

zerkms picture zerkms · Nov 3, 2010
$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