How can I perform an action within a for loop every 5 results?
Basically I\'m just trying to emulate a table with 5 columns.
This works to get a live index within the foreach loop:
'bar', 'go' => 'habs', 'CSGO_bestTeam' => 'fnatic', 'test' => 'one two', 'potato' => 'french fries', 'tomato' => 'ketchup', 'coffee' => 'expresso', 'window' => 'cleaner', 'truck' => 'load', 'nine' => 'neuf', 'ten' => 'dix');
// Numeric-Index Array of the Named-Index Array
$myNumIndex = array_keys($myNamedIndexArray);
foreach($myNamedIndexArray as $key => $value) {
$index = array_search($key,$myNumIndex);
if ($index !== false) {
echo 'Index of key "'.$key.'" is : '.$index.PHP_EOL;
if (($index+1) % 5 == 0) {
echo '[index='.$index.'] stuff to be done every 5 iterations'.PHP_EOL;
}
}
}