The foreach & trap
Loop by reference, then loop again by value with the same $v.
<?php$a = [1, 2, 3];foreach ($a as &$v) {}foreach ($a as $v) {}echo implode(',', $a), PHP_EOL;$b = [1, 2, 3];foreach ($b as &$v) {}unset($v);foreach ($b as $v) {}echo implode(',', $b), PHP_EOL;1. Predict the output
Tap the lines in the order you think they print.
- 1…
- 2…