3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $array = array('foo','bar','key'=> array('zot1','zot2','zot3')); foreach($array as $key) {var_dump($key);} foreach($array[0] as $key) {var_dump($key);} foreach($array['key'] as $key) {var_dump($key);} //foreach($array as $key=>$val) {var_dump($key)};
Output for 4.3.0 - 4.3.10, 4.4.0 - 5.0.5, 5.1.1 - 7.1.0
string(3) "foo" string(3) "bar" array(3) { [0]=> string(4) "zot1" [1]=> string(4) "zot2" [2]=> string(4) "zot3" } Warning: Invalid argument supplied for foreach() in /in/GlZH8 on line 6 string(4) "zot1" string(4) "zot2" string(4) "zot3"
Output for 5.1.0
Fatal error: fatal flex scanner internal error--end of buffer missed in /in/GlZH8 on line 8
Process exited with code 255.
Output for 4.3.11
string(3) "foo" string(3) "bar" array(3) { [0]=> string(4) "zot1" [1]=> string(4) "zot2" [2]=> string(4) "zot3" } string(4) "zot1" string(4) "zot2" string(4) "zot3"