Round Up in php

They have: 71 posts

Joined: Mar 2004

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.

They have: 71 posts

Joined: Mar 2004

Thanks, I'll see if I can figure it out from there.

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?

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's picture

They have: 840 posts

Joined: Sep 2000

*100

echo $val * 100 . "%";

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's picture

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

Abhishek Reddy's picture

He has: 3,348 posts

Joined: Jul 2001

Fyi, an asterisk is this: *
This is a commercial at: @

Smiling

netman w00t's picture

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.