ereg() or better way of rounding off?

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
Morbius
Forum Newbie
Posts: 15
Joined: Sat Jul 27, 2002 12:10 am

ereg() or better way of rounding off?

Post by Morbius »

Okay, here's the deal--ya'll might remember me, I was here a long as time ago, been away learning PHP--anyways, I am almost finished what I have been working on, but I need to either figure out how to use ereg() or is there another way to round off a number?

Basically say I have a number like pi

3.14652642 <-- Not quite, but close.

I want to -always- round it up. So I need it to hit 4 - what'd I do?
Now my major problem--at least in my head--is that, I don't understand ereg() - and the rounding needs to take place in a certain file--like user_info.php--so... does this make sense, and can anyone explain to me what i should do?
User avatar
Elmseeker
Forum Contributor
Posts: 132
Joined: Sun Dec 22, 2002 5:48 am
Location: Worcester, MA

Post by Elmseeker »

Try:

Code: Select all

<?php
$testnum = ceil(3.14652642 );
echo $testnum;
?>
This will return:

4

more info is available here:
http://www.php.net/ceil
Morbius
Forum Newbie
Posts: 15
Joined: Sat Jul 27, 2002 12:10 am

Post by Morbius »

whoa.. I love you..

lol
thanks man!
User avatar
Elmseeker
Forum Contributor
Posts: 132
Joined: Sun Dec 22, 2002 5:48 am
Location: Worcester, MA

Post by Elmseeker »

No problem, that's what we're here for...not sure about the love part tho...*ponders*
Post Reply