I have an array with 100 keys, and I want to echo all the keys, however, I want to add a
after displaying every 10th key: keys 1-10 (0-9), 11-20, 21-30…so on.
[php]//if the keys of your array are default
foreach($array as $key => $value)
{
echo $value;
if($key%10 == 0) echo ‘
’;
}
//if the array uses custom keys
$i = 0;
foreach($array as $value)
{
echo $value;
$i++;
if($i%10 == 0) echo ‘
’;
}
[/php]
You might need to swap the placement of the line break echo with the $value echo if it’s breaking on the wrong number, but those bits of code should help you on your way.