Round Up in php
In PHP, I am performing the following equation:
$dailytotal = $amount*2.2;
'
How can I tell $dailytotal to round up? Lets say $amount = 46. I want the total to be 102, not 101.2.
In PHP, I am performing the following equation:
$dailytotal = $amount*2.2;
'
How can I tell $dailytotal to round up? Lets say $amount = 46. I want the total to be 102, not 101.2.
Abhishek Reddy posted this at 01:38 — 23rd December 2004.
He has: 3,348 posts
Joined: Jul 2001
http://nz2.php.net/manual/en/function.ceil.php
airoid3000 posted this at 06:12 — 23rd December 2004.
They have: 71 posts
Joined: Mar 2004
Thanks, I'll see if I can figure it out from there.
airoid3000 posted this at 22:01 — 23rd December 2004.
They have: 71 posts
Joined: Mar 2004
I keep getting this error when I try to divide a number by zero: Warning: Division by zero
It's okay that it's zero, how can I stop the error from showing up?
airoid3000 posted this at 22:19 — 23rd December 2004.
They have: 71 posts
Joined: Mar 2004
Also, I am trying to display a percentage, how can I get this: 0.25 turned into this: 25
Thanks!
nike_guy_man posted this at 22:42 — 23rd December 2004.
They have: 840 posts
Joined: Sep 2000
*100
echo $val * 100 . "%";
airoid3000 posted this at 23:33 — 23rd December 2004.
They have: 71 posts
Joined: Mar 2004
DUH! Sorry, had a moment there. Do you know how to keep that Dividing by Zero error away?
Greg K posted this at 07:52 — 24th December 2004.
He has: 2,145 posts
Joined: Nov 2003
$var1 = 55;
$var2 = 0;
// Divide var1 by var2 would produce error
if ($var2 == 0)
echo "N/A";
else
echo $var1/var2;
-Greg
netman w00t posted this at 20:21 — 12th January 2005.
He has: 9 posts
Joined: Jan 2005
Use an asterisk to surpress the warning:
<?php
$foo = 55;
$bar = 0;
echo @ceil($foo / $bar);
?>
:: netmanw00t@Xanga :: [email protected] :: netmanw00t@delta-zero :: OpenBoard ::
Quote: oreilly.com: What advice would you give to beginning programmers who long to have skills like yours?
Pitr: Continue to kneel before me and sayink "we are not worthy" many times. And bringink me coffee.
Abhishek Reddy posted this at 00:26 — 13th January 2005.
He has: 3,348 posts
Joined: Jul 2001
Fyi, an asterisk is this: *
This is a commercial at: @
netman w00t posted this at 04:54 — 16th January 2005.
He has: 9 posts
Joined: Jan 2005
D'oh! I'm a moron.
That's what I meant to write... it's been a long day. :blush:
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.