View Single Post
Old 11-27-2012, 08:25 AM   PM User | #7
Ulysses69
New Coder

 
Join Date: May 2004
Posts: 15
Thanks: 1
Thanked 0 Times in 0 Posts
Ulysses69 is an unknown quantity at this point
Quote:
Originally Posted by sunfighter View Post
Actually it does reflect the multiple additional entries. You took the heart of the while loop out of play. Why did you do this????
Why did I do this? Because I should have known better than to do this late in the evening. Indeed, it is working:

PHP Code:
<?php
$groupsize 
4;  // OR WHAT EVER NUMBER YOU WANT
$cart = array("Apple","Pear","Banana","Peach","Orange","Coconut","Melon","Berries","Watermelon");
$test $cart;
$count 1;
while(
count($cart) % $groupsize  != 0) {
    
$cart array_merge($cart$test); // $TEST WILL ALWAYS BE THE SAME BEGING ARRAY
    
$count++;
}

$i=0;
foreach (
$cart as $row):
    
$i++;
    
$rows .= $row."\n";
    if (
$i $groupsize == 0){
    
$rows .= '-<br/>';
    }
endforeach;

echo 
'<h2>Amended List</h2><pre>'.$rows.'</pre>';
echo 
sizeof($cart);

$rows '';
foreach (
$test as $row):
    
$rows .= $row."\n";
endforeach;
echo 
'<h2>Original List</h2><pre>'.$rows.'</pre>';
echo 
sizeof($test);

?>
Thanks again, and appologies for not noticing that mistake myself.
Ulysses69 is offline   Reply With Quote