3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = array(); echo PHP_EOL . ' on empty array: ' . PHP_EOL; var_dump(key($array)); $array[] = 'f'; echo PHP_EOL . ' size one array: ' . PHP_EOL; var_dump(key($array)); echo PHP_EOL . ' within loop: ' . PHP_EOL; foreach ($array as $item) { var_dump(key($array)); } echo PHP_EOL . ' after loop: ' . PHP_EOL; var_dump(key($array)); reset($array); echo PHP_EOL . ' after reset: ' . PHP_EOL; var_dump(key($array)); end($array); echo PHP_EOL . ' after end: ' . PHP_EOL; var_dump(key($array));
Output for 4.3.10 - 4.3.11, 4.4.0, 4.4.2 - 4.4.9, 5.0.2 - 5.0.5, 5.1.0 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.28, 7.0.0 - 7.0.20, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
on empty array: NULL size one array: int(0) within loop: int(0) after loop: int(0) after reset: int(0) after end: int(0)
Output for 4.3.0 - 4.3.9, 5.0.0 - 5.0.1
Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/HZn84 on line 3 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/HZn84 on line 3 PHP_EOL on empty array: PHP_EOLNULL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/HZn84 on line 7 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/HZn84 on line 7 PHP_EOL size one array: PHP_EOLint(0) Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/HZn84 on line 10 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/HZn84 on line 10 PHP_EOL within loop: PHP_EOLint(0) Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/HZn84 on line 15 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/HZn84 on line 15 PHP_EOL after loop: PHP_EOLint(0) Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/HZn84 on line 19 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/HZn84 on line 19 PHP_EOL after reset: PHP_EOLint(0) Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/HZn84 on line 23 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/HZn84 on line 23 PHP_EOL after end: PHP_EOLint(0)
Output for 4.4.1
on empty array: NULL size one array: int(0) within loop: NULL after loop: NULL after reset: int(0) after end: int(0)

preferences:
270.72 ms | 401 KiB | 385 Q