3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $array = array('foo','bar','key'=> array('zot1','zot2','zot3')); var_dump('TEST 1'); foreach($array as $key) {var_dump($key);} var_dump('TEST 2'); foreach($array[0] as $key) {var_dump($key);} var_dump('TEST 3'); 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(6) "TEST 1" string(3) "foo" string(3) "bar" array(3) { [0]=> string(4) "zot1" [1]=> string(4) "zot2" [2]=> string(4) "zot3" } string(6) "TEST 2" Warning: Invalid argument supplied for foreach() in /in/9KR2j on line 8 string(6) "TEST 3" 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/9KR2j on line 11
Process exited with code 255.
Output for 4.3.11
string(6) "TEST 1" string(3) "foo" string(3) "bar" array(3) { [0]=> string(4) "zot1" [1]=> string(4) "zot2" [2]=> string(4) "zot3" } string(6) "TEST 2" string(6) "TEST 3" string(4) "zot1" string(4) "zot2" string(4) "zot3"