3v4l.org

run code in 300+ PHP versions simultaneously
<?php define('MAX_LOOPS',5); function withRefValue($elements, $transform) { for ($i=0; $i<$elements; $i++) { $a[] = "v.$i"; } $counter=0; foreach ($a as $k=>&$v) { eval($transform); $counter++; if ($counter>MAX_LOOPS) { break; } } echo "--> State of array after loop:\n"; var_dump($a); } echo "\nPopping elements off end of an unreferenced array, using &\$value."; $transform = 'array_pop($a);'; withRefValue(1, $transform); withRefValue(2, $transform); withRefValue(3, $transform); withRefValue(4, $transform); withRefValue(5, $transform); withRefValue(6, $transform); withRefValue(7, $transform); withRefValue(8, $transform); withRefValue(9, $transform); withRefValue(10, $transform); withRefValue(11, $transform); withRefValue(12, $transform);

preferences:
105.5 ms | 402 KiB | 5 Q