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

need help with mail()
hi i want to send an email with attaching pdf file using php. i have the following script but the pr

Simple Question
I know this is a simple question, that if I knew what it was technically called i could probably loo

Cannot Connect to Database
I am writing an application to do annual reviews. I cannot get my script to work. Whenever it runs I

$variable $variables type question
I need to be able to designate an array element dynamically, so I thought to use a variable variable

Header redirect
Hello ive got a problem ive got form with its action set to itself.
Code: <form id="f

need to apply an if/else statement to Tim Thumb script
Not sure how to work this. I essentially want to call a variety of image sizes based on which style

RSS poster script?
I have found a script that posts RSS's for me on a site that I'm building. However I would like to a

How to make a input/output field with multiple lines
Hello.
I put a input/output field on the screen but I could not change height of it. I need to

* Gridview and Detailsview in UpdatePanel, insert mode problem
I have a GridView and DetailsView working together. When a record from Gridview is selected, Detail

Bandwidth monitoring?
Hi guys,

I need a little information I have written a php app and I occurred to that I need

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