I am adding other value array inside foreach loop which working fine for me.
$i = true;
$array = array('red', 'blue');
foreach($array as $key => & $value) {
echo $value . '<br />';
if ($i === true) {
$others = array('white', 'yellow');
foreach($others as $key => & $other_value) {
$array[] = $other_value;
}
}
$i = false;
}
Output
red
blue
white
yellow
but i want to reshuffle array value inside foreach loop need output like below
red
white
yellow
blue
reshuflingduring this iteration seems useless to me and may lead to unforseen behaviour of a loop.array_mergein one line of code.