Saturday, July 20, 2013

Round up to multiple in php

7/20/2013


Here is a simple function that will round a number up to a given multiple. may this help you

<?php
/* 
Online PHP Examples with Source Code
website: http://4evertutorials.blogspot.in/
*/

function roundUpToMultiple( $number, $multiple)
{
    return ceil( $number/$multiple ) * $multiple;
} 


?>


Example Usage
<?php
/* 
Online PHP Examples with Source Code
website: http://4evertutorials.blogspot.in/
*/

echo roundUpToMultiple( 12, 7 );

?>

helpful? Share this

The Editorial Team of 4everTutorials consists of a group of PHP Professionals.

0 comments:

 

© 2014 4everTutorials. All rights resevered.

Back To Top