3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function arr($array) { var_dump(key($array)); var_dump(current($array)); } $a = array('a' => 1, 'b' => 2, 'c' => 3); arr($a); next($a); arr($a); var_dump(key($array)); var_dump(current($array));
Output for 7.0.0 - 7.1.0
string(1) "a" int(1) string(1) "b" int(2) Notice: Undefined variable: array in /in/U2mTH on line 14 Warning: key() expects parameter 1 to be array, null given in /in/U2mTH on line 14 NULL Notice: Undefined variable: array in /in/U2mTH on line 15 Warning: current() expects parameter 1 to be array, null given in /in/U2mTH on line 15 NULL
Output for hhvm-3.10.0 - 3.12.0
string(1) "a" int(1) string(1) "b" int(2) Warning: Invalid operand type was used: expecting an array in /in/U2mTH on line 14 bool(false) Warning: Invalid operand type was used: expecting an array in /in/U2mTH on line 15 bool(false)
Output for 5.3.0 - 5.6.28
string(1) "a" int(1) string(1) "b" int(2) Warning: key() expects parameter 1 to be array, null given in /in/U2mTH on line 14 NULL Warning: current() expects parameter 1 to be array, null given in /in/U2mTH on line 15 NULL
Output for 5.2.4 - 5.2.17
string(1) "a" int(1) string(1) "b" int(2) Warning: key(): Passed variable is not an array or object in /in/U2mTH on line 14 bool(false) Warning: current(): Passed variable is not an array or object in /in/U2mTH on line 15 bool(false)
Output for 4.3.2 - 4.4.0, 4.4.2 - 5.2.3
string(1) "a" int(1) string(1) "a" int(1) Warning: key(): Passed variable is not an array or object in /in/U2mTH on line 14 bool(false) Warning: current(): Passed variable is not an array or object in /in/U2mTH on line 15 bool(false)
Output for 4.4.1
string(1) "a" int(1) string(1) "b" int(2) Notice: Undefined variable: array in /in/U2mTH on line 14 Warning: key(): Passed variable is not an array or object in /in/U2mTH on line 14 bool(false) Notice: Undefined variable: array in /in/U2mTH on line 15 Warning: current(): Passed variable is not an array or object in /in/U2mTH on line 15 bool(false)
Output for 4.3.0 - 4.3.1
string(1) "a" int(1) string(1) "a" int(1) Warning: key() [http://www.php.net/function.key]: Passed variable is not an array or object in /in/U2mTH on line 14 bool(false) Warning: current() [http://www.php.net/function.current]: Passed variable is not an array or object in /in/U2mTH on line 15 bool(false)