Rounding a number queried from a database


Posted on 16th Feb 2014 07:03 pm by admin

I know that to display a rounded number you just do echo "round($number)";. But how would I convert the $number varible into a rounded number, so that when I say echo "$number"; the rounded number shows up? For example I have a calculation that calculates the distance between two locations using longitude and latitude. $distance is the final result. But $distance is a very long decimal number. To do further calculations with it, I would like to round $distance so that it has no decimal places anymore (So 1482.894736593 would = 1483). So $distance would now equal 1483, not 1482.894736593. Then I could go on and calculate the time, cost, etc. and $number will stay rounded.

Did you know?Explore Trending and Topic pages for more stories like this.
Do you know what I am saying?
No comments posted yet

Your Answer:

Login to answer
252 Like 8 Dislike
Previous forums Next forums
Other forums

Wierd echo error?
Hi, i got the most wierd php error ever and i don't know why..
Code: echo "<t

asking for direction
I have 2 tables in my data, which are "post" and "event"
I won't make a summa

apart from cron
I need to run a php file every one hour. Is there any other solution apart from cron job?

Simple AND question
Hello,

I've got following code:

Code: if(strpos($row[13],"http://")

str_replace help
Hey there,

I'm a PHP newb, I'm having troubles with the str_replace function. I want to clean

search function
HI guys,

if anyone could point us in the right direction of how to do this, or provide some t

Retreiving objects from Sessions
Hi all,

I am getting really frustrated with storing and retreiving objects from a session. Bu

DOMDocument
Hello All,

I need to take an XML document, modify some of the nodes in it and then perform a

Need help to modify php ELSE code
I'm trying to find a way to have the php code display a message if there is no inventory listed in t

How to insert random unique values in 2 columns ?
I have table with 2 columns

Create Table code_for_code (
first_code varchar2(10) uni

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash