Jump to content


Photo

php maths help


  • Please log in to reply
1 reply to this topic

#1 Canman2005

Canman2005
  • Members
  • PipPipPip
  • Advanced Member
  • 669 posts

Posted 08 June 2006 - 05:45 AM

Hello everyone

I have a php page which prints two number values, one of the numbers is a percentage and the other is a total amount. It looks like;

Percentage: 22
Total: 500

Can PHP work out percentages? So my example would be

22% of 550

and then print out the toal on the page with the percentage deducted from the total? Tried a few ideas but cannot seem to get it to work

Any help would be ace

Thanks in advance

Mark



#2 samshel

samshel
  • Members
  • PipPipPip
  • Advanced Member
  • 837 posts

Posted 08 June 2006 - 06:31 AM

$percentage = 22;
$total = 550;

echo $percentage."% of ".$total." is ".($total * $percentage/100 );
Cheers,
SamShel
-----------------------------------------------
--: FUTURE IS LINUX :--
-----------------------------------------------




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users