$pie = array('Apple' => 1, 'Cherry' => 3, 'Pumpkin' => 6);
reset($pie);
while (list($k, $v) = each($pie)) {
echo "$k => $v
";
$desserts[]=$pie;
}
If the $desserts[]=$pie
line is commented out, this code block executes as expected.
Why when it is uncommented does it go into an infinite loop?
I do not understand why that happens. This is a perfect example of what NOT to do, but I don't understand why the complete array is printed over and over. I thought just the first slice would be repeated.