3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr = ['one', 'two', 'three', 'four', 'five']; echo 'Current value: ' . current($arr) . "\n"; foreach ($arr as $a) { if ($a === 'three') break; } echo 'Did it change? ' . current($arr) . "\n"; function withRef(array &$arr): void { foreach ($arr as $a) { if ($a === 'three') break; } } withRef($arr); echo 'What about now? ' . current($arr) . "\n";

preferences:
29.36 ms | 404 KiB | 5 Q