By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,278 Members | 1,358 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,278 IT Pros & Developers. It's quick & easy.

Re: This a question for al the geniuses in math, Looking for a math formula to get a value

P: n/a
..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
Oct 9 '08 #1
Share this Question
Share on Google+
1 Reply


P: n/a
SM
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.
Oct 10 '08 #2

This discussion thread is closed

Replies have been disabled for this discussion.