1. Rounding up

Let's say I do this:

10 / 3 = 3.33333

What would I do to round up to 4? I'm displaying 3 photos per page. I calculate how many pages I need by dividing the number of photos by how many I display on each page. 10 photos / 3 photos per page should equal 4 pages, but round(10 / 3) gives 3.

Solutions?

Thanks,

David

2. Originally Posted by dkroll
Let's say I do this:

10 / 3 = 3.33333

What would I do to round up to 4? I'm displaying 3 photos per page. I calculate how many pages I need by dividing the number of photos by how many I display on each page. 10 photos / 3 photos per page should equal 4 pages, but round(10 / 3) gives 3.

Solutions?

Thanks,

David
Use ceil(). It will round UP your numbers.

ie: \$pages = ceil(10/3); // would equal 4

3. correction, the function name is ceil()

4. Yeah, that's the one! (...I really dislike that word, "ceiling"...)

5. what about floor() is that one better

6. At least I can spell "floor"!

7. Lol, with PHP, spelling counts

Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•