3v4l.org

run code in 300+ PHP versions simultaneously
<?php function print_while_each($list) { while (list($key, $val) = each($list)) { echo $key, $val; if ($val == '2') { $list[] = 4; } } } function print_foreach($list) { foreach ($list as $key => $val) { echo $key, $val; if ($val == '2') { $list[] = 4; } } } function print_while_next($list) { $val = reset($list); while (!empty($val)) { $key = key($list); $val = current($list); echo $key, $val; if ($val == '2') { $list[] = 4; } $val = next($list); } } $list = array('1', '2', '3'); print_while_each($list); echo '<br>', PHP_EOL; print_foreach($list); echo '<br>', PHP_EOL; print_while_next($list); echo '<br>', PHP_EOL;
Output for git.master, git.master_jit, rfc.property-hooks
Fatal error: Uncaught Error: Call to undefined function each() in /in/g77Ae:4 Stack trace: #0 /in/g77Ae(37): print_while_each(Array) #1 {main} thrown in /in/g77Ae on line 4
Process exited with code 255.

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
27.12 ms | 405 KiB | 5 Q