3v4l.org

run code in 500+ PHP versions simultaneously
<?php function special_array() { $x = 42; return [&$x, &$x]; } foreach (special_array() as $x) { var_dump($x); $x++; } foreach (special_array() as &$x) { var_dump($x); $x++; // This _does_ have an effect. }
Output for 8.1.32 - 8.1.34, 8.2.0 - 8.2.34, 8.3.0 - 8.3.35, 8.4.1 - 8.4.26, 8.5.0 - 8.5.11
int(42) int(42) int(42) int(43)

preferences:
30.8 ms | 1496 KiB | 7 Q