jwk811 Posted January 14, 2007 Share Posted January 14, 2007 how can i round a number to the nearest 10? round function wouldnt work because it rounds only to the nearest integer... Link to comment https://forums.phpfreaks.com/topic/34179-round-to-the-nearest-10-how-can-i-do-that/ Share on other sites More sharing options...
Hypnos Posted January 14, 2007 Share Posted January 14, 2007 I'm pretty sure this should do it:[code=php:0]$rounded = round($x, -1);[/code] Link to comment https://forums.phpfreaks.com/topic/34179-round-to-the-nearest-10-how-can-i-do-that/#findComment-160812 Share on other sites More sharing options...
Barand Posted January 14, 2007 Share Posted January 14, 2007 to round to nearest N[code]<?php$N = 10;$x = 14;echo round($x/$N) * $N;?>[/code] Link to comment https://forums.phpfreaks.com/topic/34179-round-to-the-nearest-10-how-can-i-do-that/#findComment-160814 Share on other sites More sharing options...
jwk811 Posted January 14, 2007 Author Share Posted January 14, 2007 also how could i round a number so it goes up to the nearest integer.. i dont want it to round down ever always up and round doesnt do that.. i actually need the 10 rounded up to.. how could i do that Barand? Link to comment https://forums.phpfreaks.com/topic/34179-round-to-the-nearest-10-how-can-i-do-that/#findComment-160815 Share on other sites More sharing options...
Barand Posted January 14, 2007 Share Posted January 14, 2007 ceil() Link to comment https://forums.phpfreaks.com/topic/34179-round-to-the-nearest-10-how-can-i-do-that/#findComment-160816 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.