3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $array = array('foo','bar','key'=> array('piff','puff','paff')); 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);}
Output for 5.2.3 - 5.6.21, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
string(6) "TEST 1" string(6) "TEST 2" Warning: Invalid argument supplied for foreach() in /in/eCmW8 on line 8 string(6) "TEST 3" string(4) "piff" string(4) "puff" string(4) "paff"
Output for 4.3.0 - 4.3.10, 4.4.0 - 5.2.2
string(6) "TEST 1" string(6) "TEST 2" <br /> <b>Warning</b>: Invalid argument supplied for foreach() in <b>/in/eCmW8</b> on line <b>8</b><br /> string(6) "TEST 3" string(4) "piff" string(4) "puff" string(4) "paff"
Output for 4.3.11
string(6) "TEST 1" string(6) "TEST 2" string(6) "TEST 3" string(4) "piff" string(4) "puff" string(4) "paff"