//if ImagesPerPage is not evenly divisable by ImageCount it creates an extra page
if (($ImageCount % $ImagesPerPage) > 0) {
$TotalPages = $ImageCount / $ImagesPerPage + 1;
//Converts into an absolute number number ie. 8.3 or 8.99999 equal 8
$TotalPages = sprintf("%01.0f", $TotalPages);
} else {
//the amount of images divides perfectly by the images per page
$TotalPages = $ImageCount / $ImagesPerPage;
}
//End of finding total pages
I cannot get $TotalPages to equal the correct number. This is for a photo gallery script I am making, it calculates how many images are in a certain directory, then it MODS that by the amount of images per page. If there is a remainder (total pics not cleanly divisable by the amount of pics per page) the script will add 1 extra page to $TotalPages for these stray pictures.
This script should work but I keep getting incorrect numbers for $TotalPages because it keeps rounding the number when I do the sprintf command. Is there something I could do to take a number such as 8.33 or 8.999999 and turn it into 8?