3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $array = array('a' => '…', 'b' => '…', 'c' => '…', 'd' => '…', 'e' => '…', 'f' => '…'); foreach ($array as $key => $val){ echo "current key: $key, next key: ".key(($array))."<br>"; }
Output for 5.1.0 - 5.2.3, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
current key: a, next key: a<br>current key: b, next key: a<br>current key: c, next key: a<br>current key: d, next key: a<br>current key: e, next key: a<br>current key: f, next key: a<br>
Output for 4.4.1, 5.4.0 - 5.6.28
current key: a, next key: b<br>current key: b, next key: c<br>current key: c, next key: d<br>current key: d, next key: e<br>current key: e, next key: f<br>current key: f, next key: <br>
Output for 5.2.9 - 5.3.29
Strict Standards: Only variables should be passed by reference in /in/s1RhD on line 4 current key: a, next key: b<br> Strict Standards: Only variables should be passed by reference in /in/s1RhD on line 4 current key: b, next key: c<br> Strict Standards: Only variables should be passed by reference in /in/s1RhD on line 4 current key: c, next key: d<br> Strict Standards: Only variables should be passed by reference in /in/s1RhD on line 4 current key: d, next key: e<br> Strict Standards: Only variables should be passed by reference in /in/s1RhD on line 4 current key: e, next key: f<br> Strict Standards: Only variables should be passed by reference in /in/s1RhD on line 4 current key: f, next key: a<br>
Output for 5.2.4 - 5.2.8
current key: a, next key: b<br>current key: b, next key: b<br>current key: c, next key: b<br>current key: d, next key: b<br>current key: e, next key: b<br>current key: f, next key: b<br>
Output for 4.3.2 - 4.4.0, 5.0.0 - 5.0.5
Fatal error: Only variables can be passed by reference in /in/s1RhD on line 4
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Notice: Only variables can be passed by reference in /in/s1RhD on line 4 current key: a, next key: a<br> Notice: Only variables can be passed by reference in /in/s1RhD on line 4 current key: b, next key: a<br> Notice: Only variables can be passed by reference in /in/s1RhD on line 4 current key: c, next key: a<br> Notice: Only variables can be passed by reference in /in/s1RhD on line 4 current key: d, next key: a<br> Notice: Only variables can be passed by reference in /in/s1RhD on line 4 current key: e, next key: a<br> Notice: Only variables can be passed by reference in /in/s1RhD on line 4 current key: f, next key: a<br>
Output for 4.3.0 - 4.3.1
Fatal error: Only variables can be passed by reference in /in/s1RhD on line 4