Loop through an array and keep track of previous, next item, current item, etc.