Finding an item's position in an array, and then returning previous and next items |
[eluser]Daniel H[/eluser]
Guys, I wonder if anyone can explain how I can do this presumably straight forward thing. Consider an array like this, e.g. Code: Array On a page, I'm displaying work example whose ID is 27946, i.e. key[1]. How then would I firstly locate this value in the array, and then return ID 27945 (next) and ID 27947 (previous)? Many thanks, Dan.
[eluser]xwero[/eluser]
from php.net array_search comments Code: function fktMultiArraySearch($arrInArray,$varSearchValue){ Code: function surrounding_rows($array,$key) Code: $rows = surrounding_rows($files,fktMultiArraySearch($files,27946));
[eluser]Daniel H[/eluser]
That works beautifully - thank you so much for helping. |
Welcome Guest, Not a member yet? Register Sign In |