Q. What will be the output?
Code:$arr = [1,2,3];
foreach($arr as &$v) {}
foreach($arr as $v) {}
print_r($arr);
β
Correct Answer: (B)
[1,2,2]
Explanation: Reference variable remains bound causing last element overwrite.