On Oct 9, 6:37*pm, Michael Fesser <neti...@gmx.dewrote:

.oO(SM)

I've posted the following question in a math group. I'll keep you

posted:

I need to find a mathematical formula for this next problem...

I have a list containing 13 items. The list is dynamic, wich means

that sometimes it could contains 20 items or 35 items o only 4 items.

I want to show the items in groups of 4. Again, this is dynamic.

Sometimes i want to show the items in groups of 11, 2, etc...

So, if i have 34 items and i want to show it in groups of 10, I would

end up having 4 groups (3 groups of 10, and 1 group of 4)... So far so

good. Let's continue. If item 'joe' is the 12th item, then item 'joe'

is in group 2. right? If the item 'banana' is the 8th item, then item

'banana' is in group 1...and so on...

<?php

$itemsPerGroup = 10;

$itemPosition = 12;

$group = ceil($itemPosition/$itemsPerGroup);

var_dump($group);

?>

Micha

Thanks, just what i need it.