Is anyone already aware of how to push an element/value onto an array, while inside an iterating loop using that array, and still be able to use that element/value in the loop?
I wasn't until today. Very grateful to "Oleg" who, in the PHP manual comments for [man]foreach/man, pointed this out (I was in a foreach() loop and had tried both array_push() and bracket notation to no avail:
$array = range(1,10);
while (list($arr,$val) = each( $array )) {
if ($val == 5) {
$array[] = 11;
}
echo $val.PHP_EOL;
}
So, if your Real Name(tm) is "Oleg" and you wrote that comment, thank you very much!
(Are there any other ways to do this?)