Q. What will be the output?
Code:
$a = [1,2,3];
foreach($a as $k => &$v) {}
foreach($a as $k => $v) {}
print_r($a);
β
Correct Answer: (B)
[1,2,2]
Explanation: Reference persists, affecting last element.