Page 1 of 1

ereg() or better way of rounding off?

Posted: Thu Jan 02, 2003 3:05 pm
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?

Posted: Thu Jan 02, 2003 3:19 pm
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

Posted: Thu Jan 02, 2003 3:22 pm
by Morbius
whoa.. I love you..

lol
thanks man!

Posted: Thu Jan 02, 2003 4:11 pm
by Elmseeker
No problem, that's what we're here for...not sure about the love part tho...*ponders*