Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old October 9th, 2008, 11:45 PM
Michael Fesser
Guest
 
Posts: n/a
Default Re: This a question for al the geniuses in math, Looking for a math formula to get a value

..oO(SM)
Quote:
>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
  #2  
Old October 10th, 2008, 04:55 AM
SM
Guest
 
Posts: n/a
Default Re: This a question for al the geniuses in math, Looking for a mathformula to get a value

On Oct 9, 6:37*pm, Michael Fesser <neti...@gmx.dewrote:
Quote:
.oO(SM)
>
>
>
Quote:
I've posted the following question in a math group. I'll keep you
posted:
>
Quote:
I need to find a mathematical formula for this next problem...
>
Quote:
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.
>
Quote:
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...
>
Quote:
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.
 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles