<?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);
You have javascript disabled. You will not be able to edit any code.