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.

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

PHP mail() returns true but doesn't work
First off I apologize if this is a newbie question, and I generally don't like asking questions that

Select Lists into MYSQL
Hello All, I am new to PHP @ 1 week. So borrowing code anywhere I can. I am making progress, but h

urldecode question
How would I format this line of code properly?

<?php echo urldecode($_GET['Title']); ?

Anti Spam Code
Ok where do i start? Probably by telling you I have very little working knowledge of PHP and that I

This is driving me nuts!
This insert query looks to be alright, however I get this error:

QuoteYou have an error in yo

Upload simple problem
Really confused!! I run once and it worked, but when i tried today...it didn't work

Which par

include
Hi I have this way of licensing my PHP application, and I want to know if you guys can answer some q

BI in Upstream Production operations
Appreciate if you can assist in the following areas:
1) Examples of life before and after BI i

selection tool on raster image
Hi!
I have to implement in my app a selection tool which lets users to select region of any shape

Update Database
Hi All,


I have a problem with this:

Code: [Select]<?php
session_start();

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