Math Functions?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
g-force2k2
Forum Newbie
Posts: 12
Joined: Thu Apr 18, 2002 8:15 pm

Math Functions?

Post 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 =_-
User avatar
sam
Forum Contributor
Posts: 217
Joined: Thu Apr 18, 2002 11:11 pm
Location: Northern California
Contact:

Post 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
g-force2k2
Forum Newbie
Posts: 12
Joined: Thu Apr 18, 2002 8:15 pm

Post 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?
Post Reply