3v4l.org

run code in 300+ PHP versions simultaneously
<?php // simulate the array $arr = [0=>'a',8=>'b',2=>'c',7=>'d',9=>'e',11=>'f']; // iterate it without messing with its internal pointer for($i=0;$i<count($arr);$i++) $arr[key($arr)] = ["current" => current($arr), "next" => next($arr)]; // test it print_r($arr);

preferences:
26.8 ms | 407 KiB | 5 Q