PhpSnip.com

User Stats

Round up

Takes a number like 1000.000001 and rounds it to 1001, or 1000.9 and rounds it to 1001 I made this for my paginator which gets the total pages then divides by amount per page, sometimes it returns 1.1 or 1.00001 etc, so it rounds it up for a solid number to use for the paginator

Info

 Download  View Source (print view)
 Rating : 4.7  Views : 1228

Source Code ( 23 lines )

Heres a nice function I made for my pagination that rounds to the next number if the number is greater than the whole number.

EX: 2.000001 will return 3
2.5 will return 3
2 will return 2
1.9 or 1.3 etc will return 2

Can use it as long as copyright remains intact.

<?php
function round_up($Number) {
	// Copyright Josh Acecool M http://www.acecoolco.com
	if ($Number > number_format($Number, "0")) {
		$Number = round($Number);
		$Number++;
	}
	else
	{
		$Number = number_format($Number, "0");
	}
	return $Number;
}
?>

Search

Subscribe

  Rss Feeds

Sponsors

Advertise