3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $array = array ('a','b','c','d'); $keys = array_keys($array); for ($i = 0; $i < count($keys); $i++) { $cur = $array[$keys[$i]]; $next = $array[$keys[$i+1]]; echo "current item: ".$cur; echo "\n"; echo "next item: ".$next; echo "\n"; }
based on rA8qk
Output for 5.3.0 - 7.2.0
current item: a next item: b current item: b next item: c current item: c next item: d Notice: Undefined offset: 4 in /in/fOXIp on line 8 Notice: Undefined index: in /in/fOXIp on line 8 current item: d next item:
Output for 4.3.0 - 5.2.17
current item: a next item: b current item: b next item: c current item: c next item: d Notice: Undefined offset: 4 in /in/fOXIp on line 8 Notice: Undefined index: in /in/fOXIp on line 8 current item: d next item: