Solved

Find nearest number php

Posted on 2014-11-25
2
78 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 50

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
tripleUp challenge 7 93
groupNoAdj 7 116
mapBully challenge 6 178
Is there a canned solution for a custom genealogy website 2 109
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
The goal of this video is to provide viewers with basic examples to understand and use conditional statements in the C programming language.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

730 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