Page 1 of 1

Math Functions?

Posted: Thu Apr 18, 2002 8:47 pm
by g-force2k2
I trying to learn a little about the math functions of PHP and i see that... floor = is rounded up and that round is just rounding... but how would i do like a percentage type thing... like rand() ? would that do the trick? And also for logs how exactly do they work ;/ sorry i don't know... one more thing... having a comma in a math function followed by a number what does that do? is it an array? example:

Code: Select all

$total = floor ($posts / 6, 1);
what exactly does that mean? sorry for all the questions =_-

Posted: Thu Apr 18, 2002 11:19 pm
by sam
By percentage I'm going to assume that you want to get the percentage that one number has of the total of a few numbers. IE

Code: Select all

$single = 93;
$married = 74;
$devorced = 102;
and you want to find out what percent is married:

Code: Select all

$total = $single + $married + $devorced;
$percent = ($married * 100) / $total;
echo $percent . "% are married";
Cheers Moe

Posted: Mon Apr 22, 2002 9:10 pm
by g-force2k2
thanks for the tip sam but i was actually reffering to random numbers... like using a... function...

Code: Select all

rand()
how would i get that to work?