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

Problem with coding MySQL query
I'm having heaps of trouble getting one of my PHP/MySQL queries to work for some reason (and the fun

Strange HTML Tag?
I recently noticed some odd HTML appear in some of the websites I host. Not all of them are run on a

Saving PHP output as a file
I wondered if anyone knows how to save the rendered output of a PHP script as a file?

I have

php and downloading
I want to use a php script to create two files. Then I want it to redirect (or whatever) to have tho

issues verifying if user is logged in
I am having issues when a user logs in via asp Login control, the IsAuthenticated still seems to com

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

url- go to webpage
i have an input text field and submit button.

how do i make the url entered into the textfiel

Putting double spaces instead of single spaces
Im looking at trying to replace all single spacing between fields with double spacing

At pres

Help? Need help on project with templates involving mysql and php.
I'm having a hard time explaining what I want but basically here is what I have in place:

-Da

start new row of pictures
on my site www.budstreasureauctions.com there is a featured auctions box that users will pay to get

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