Pretty basic maths question [SOLVED]

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
Stryks
Forum Regular
Posts: 746
Joined: Wed Jan 14, 2004 5:06 pm

Pretty basic maths question [SOLVED]

Post by Stryks »

At least I think it is. I'm useless at maths.

Anyhow, I've got an array filled with filenames, built by pulling a file list from a directory structure, and I'm using it to display files found (images) in a gallery page.

I'm pretty much set up, with 3 images across (generated thumbnails) and I'm looking at 4 rows.

So ... my simple question is, how do I go about getting the number of times 12 goes into the number of array elements without a remainder.

I mean, I can find the remainder easily enough with something like

Code: Select all

if($img_count % 12)  $page_count++;
to increase the page count to cover the extra images.

I just dont know how to get how many base pages it will take. :oops:

Any help?
Last edited by Stryks on Tue Mar 06, 2007 9:52 pm, edited 1 time in total.
User avatar
Stryks
Forum Regular
Posts: 746
Joined: Wed Jan 14, 2004 5:06 pm

Post by Stryks »

Damn ... thats embarrassing.

I worked it out just after I posted it.

Code: Select all

$page_count = (($img_count - ($img_count % 12)) / 12);
			if($img_count % 12)  $page_count++;
Thanks
Post Reply