3v4l.org

run code in 300+ PHP versions simultaneously
<?php $tables = [ [ 'key1' => 'value1', 'key2' => 'value2' ], [ 'key3' => 'value3', 'key4' => 'value4' ], ]; echo 'List Each' . \PHP_EOL; foreach ($tables as $table_array) { list(,$table) = each($table_array); var_dump($table); } echo \PHP_EOL; echo 'Array Shift'. \PHP_EOL; foreach ($tables as $table_array) { $table = array_shift($table_array); var_dump($table); } echo \PHP_EOL; echo 'Current Next' . \PHP_EOL; foreach ($tables as $table_array) { $table = current($table_array); var_dump($table); next($table_array); } echo \PHP_EOL; echo 'Current Next w/key' . \PHP_EOL; foreach ($tables as $table_array) { $key = key($table_array); $table = current($table_array); var_dump($key, $table); next($table_array); }
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.4, 8.3.6
List Each Fatal error: Uncaught Error: Call to undefined function each() in /in/8vie4:17 Stack trace: #0 {main} thrown in /in/8vie4 on line 17
Process exited with code 255.
Output for 8.3.5
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0 List Each Fatal error: Uncaught Error: Call to undefined function each() in /in/8vie4:17 Stack trace: #0 {main} thrown in /in/8vie4 on line 17
Process exited with code 255.
Output for 7.2.0 - 7.2.33, 7.3.16 - 7.3.31, 7.4.0 - 7.4.33
List Each Deprecated: The each() function is deprecated. This message will be suppressed on further calls in /in/8vie4 on line 17 string(6) "value1" string(6) "value3" Array Shift string(6) "value1" string(6) "value3" Current Next string(6) "value1" string(6) "value3" Current Next w/key string(4) "key1" string(6) "value1" string(4) "key3" string(6) "value3"
Output for 5.6.38, 7.1.0 - 7.1.23, 7.3.32 - 7.3.33
List Each string(6) "value1" string(6) "value3" Array Shift string(6) "value1" string(6) "value3" Current Next string(6) "value1" string(6) "value3" Current Next w/key string(4) "key1" string(6) "value1" string(4) "key3" string(6) "value3"

preferences:
175.28 ms | 402 KiB | 173 Q