Using next in foreach loop
It will not affect your loop if you use it in this way
<?php
$lists = range('a', 'f');
foreach($lists as &$value) {
$next = current($lists);
echo 'value: ' . $value . "\n" . 'next: ' . $next . "\n\n";
}
OUTPUT
value: a next: b
value: b next: c
value: c next: d
value: d next: e
value: e next: f
value: f next: