<?php

// This code supposed to find adjacent items of a specific one
// $list is an array of ids
// $itemToSearch is an id that might be in the $list

foreach ($list as $item) {
    next($list);
    if ($item == $itemToSearch) {
        break;
    }
    $previousItem = $item;
}
$nextItem = current($list);

The $list variable is a list of ids, e.g [1, 2, 3, 4, 5] The $itemToSearch is an id that might be in $list

By baueri, 2022-05-31 17:30:21