Solved

Find nearest number php

Posted on 2014-11-25
2
83 Views
Last Modified: 2015-08-14
How to find the nearest tenth number in php.
Example: if input is 58, output should be 60
if input is 92, the output should be 90

Thanks.
0
Comment
Question by:rameshitm
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 51

Expert Comment

by:Rgonzo1971
ID: 40464210
Hi,

pls try

$number = round($input / 10) * 10;

Regards
0
 
LVL 84

Accepted Solution

by:
ozo earned 500 total points
ID: 40464220
echo round(58, -1);
echo round(92, -1);
0

Featured Post

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There is an easy way, in .NET, to centralize the treatment of all unexpected errors. First of all, instead of launching the application directly in a Form, you need first to write a Sub called Main, in a module. Then, set the Startup Object to th…
This article will show, step by step, how to integrate R code into a R Sweave document
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question