i have this array of id’s: $products=array(2151, 2563, 2015, 1986, 1985);
What i want is to build a function that will return the next and the previous item each time i pass an id. For example when i have lets say the 2563-id to get a response with 2151 & 2015.
Any suggestions will be appreciated.
Then you do the checks since
$products[$index +/- 1]will not always exist!