3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr = ['a', 'b', 'c']; var_dump(current($arr)); echo '--------aaaaaa--------', PHP_EOL; var_dump(end($arr)); var_dump(next($arr)); $abc = $arr; echo '--------bbbbbbb--------', PHP_EOL; var_dump(current($abc)); // false var_dump(current($abc)); // false var_dump(each($abc)); // not false??? var_dump(each($abc)); // not false??? var_dump(each($abc)); // not false??? echo '--------cccccccc--------', PHP_EOL;
Output for 8.0.0 - 8.0.3
string(1) "a" --------aaaaaa-------- string(1) "c" bool(false) --------bbbbbbb-------- bool(false) bool(false) Fatal error: Uncaught Error: Call to undefined function each() in /in/dGZbf:14 Stack trace: #0 {main} thrown in /in/dGZbf on line 14
Process exited with code 255.
Output for 7.2.0 - 7.2.33, 7.3.16 - 7.3.27, 7.4.0 - 7.4.15
string(1) "a" --------aaaaaa-------- string(1) "c" bool(false) --------bbbbbbb-------- bool(false) bool(false) Deprecated: The each() function is deprecated. This message will be suppressed on further calls in /in/dGZbf on line 14 array(4) { [1]=> string(1) "a" ["value"]=> string(1) "a" [0]=> int(0) ["key"]=> int(0) } array(4) { [1]=> string(1) "b" ["value"]=> string(1) "b" [0]=> int(1) ["key"]=> int(1) } array(4) { [1]=> string(1) "c" ["value"]=> string(1) "c" [0]=> int(2) ["key"]=> int(2) } --------cccccccc--------
Output for 7.0.0 - 7.0.20, 7.1.0 - 7.1.20
string(1) "a" --------aaaaaa-------- string(1) "c" bool(false) --------bbbbbbb-------- bool(false) bool(false) array(4) { [1]=> string(1) "a" ["value"]=> string(1) "a" [0]=> int(0) ["key"]=> int(0) } array(4) { [1]=> string(1) "b" ["value"]=> string(1) "b" [0]=> int(1) ["key"]=> int(1) } array(4) { [1]=> string(1) "c" ["value"]=> string(1) "c" [0]=> int(2) ["key"]=> int(2) } --------cccccccc--------