Thanks, that works as desired.
Is there however, an alternative to array_merge function, so that the appended array data is pushed to the array? as it is, the $cart array stays the original size and not representive of the multiple additional entires that I was after, despite these entries properly populating the $rows variable in the example.
PHP Code:
<?php
$groupsize = 3; // 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
$cart = $cart + $test;
//print_r($cart);
//echo "<br />".count($cart)."<br /><br />";
$count++;
}
foreach ($test as $row):
$rows .= $row."\n";
endforeach;
echo '<h2>Original List</h2><pre>'.$rows.'</pre>';
echo sizeof($test);
$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);
?>
I am grateful for your help, and am just wondering if there is an alternative to array_merge to do this, without creating a new array just for this purpose.