Jump to content


Photo

calculating percentages


  • Please log in to reply
2 replies to this topic

#1 Synergic

Synergic
  • Members
  • PipPip
  • Member
  • 21 posts

Posted 30 September 2006 - 08:11 AM

i don't know why the following isn't working. I'm trying to calculate 10% of a value?

$a = 10/100;
$b = 0;
$b = $a*$b;
echo $b;

it just gives me 0 :|


#2 extrovertive

extrovertive
  • Members
  • PipPipPip
  • Advanced Member
  • 235 posts

Posted 30 September 2006 - 08:18 AM

Remember in pre-school A*0 = 0? Anything times zero becomes 0 right?

$val = (val);

$newval = $val - (.10*$val);



#3 Synergic

Synergic
  • Members
  • PipPip
  • Member
  • 21 posts

Posted 30 September 2006 - 08:25 AM

heh whoops yes it works now:


$a = 10/100;
			$b = 1000;
			$b = $a*$b;
			echo $b;





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users