Skip to content

Instantly share code, notes, and snippets.

function getNextFactId($currentId, $EveryCroid) {
reset($EveryCroid);
while (!in_array(current($EveryCroid), [$currentId, null])) {
next($EveryCroid);
}
$nextFactId = next($EveryCroid);
if ($nextFactId > end($EveryCroid)) {
$$nextFactId = reset($EveryCroid);
}
return $nextFactId;