RE: [PHP] Math Question....
| From: | Jason | Date: | Thu, 22 Apr 2010 14:37:03 +0000 |
| Subject: | RE: [PHP] Math Question.... | ||
| References: | 1 2 3 4 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-304424@lists.php.net to get a copy of this message | ||
-----Original Message-----
From: Ashley Sheridan [mailto:ash@ashleysheridan.co.uk]
Sent: 22 April 2010 15:13
To: Dan Joseph
Cc: PHP eMail List
Subject: Re: [PHP] Math Question....
On Thu, 2010-04-22 at 10:17 -0400, Dan Joseph wrote:
> On Thu, Apr 22, 2010 at 10:12 AM, Stephen <stephen-d@rogers.com> wrote:
>
> > 1,252,398 DIV 30 = 41,746 groups of 30.
> >
> > 1,252,398 MOD 30 = 18 items in last group
> >
> Well, the only problem with going that route, is the one group is not
> equally sized to the others. 18 is ok for a group in this instance, but
if
> it was a remainder of only 1 or 2, there would be an issue. Which is
where
> I come to looking for a the right method to break it equally.
>
>
>
>How do you mean break it equally? If the number doesn't fit, then you've
>got a remainder, and no math is going to change that. How do you want
>that remainder distributed?
>
>Thanks,
>Ash
>http://www.ashleysheridan.co.uk
>
>
>
Perhaps a round-robin approach is called for?
<?
$items=1252398;
$groupsize=30;
for ($i=0;$i<$items;$i++)
$grouparray[$i % $groupsize][]=$i;
print_r($grouparray);
?>
HTH
J