On Thu, 22 Apr 2010 10:49:11 -0400 Peter van der Does <pvanderdoes@xxxxxxxxx> wrote: > > My take on it: > > $Items=1252398; > $MaxInGroup=30; > for ($x=$MaxInGroup; $x>1;$x--) { > $remainder=$Items % $x; > // Change 17 to the max amount allowed in the last group > if ($remainder == 0 || $remainder >= 17) { // > $groups = (int) ($Items /$x)+1; > echo $groups."\n"; > echo $remainder; > break; > } > } > Bugfixed LOL: $Items=1252398; $MaxInGroup=30; for ($x=$MaxInGroup; $x>1;$x--) { $remainder=$Items % $x; // Change 17 to the max amount allowed in a group if ($remainder == 0 || $remainder >= 17) { $groups = (int) ($Items /$x); if ($remainder > 0 ) { $groups++; } echo $groups."\n"; echo $remainder; break; } } -- Peter van der Does GPG key: E77E8E98 IRC: Ganseki on irc.freenode.net Twitter: @petervanderdoes WordPress Plugin Developer Blog: http://blog.avirtualhome.com Forums: http://forums.avirtualhome.com Twitter: @avhsoftware -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php