PHP数组对象内部导航模式

I have an array of objects, and want the objects to be able to reference their 'neighbors' (the next and previous objects in the array). Is there an existing pattern to do that?

Perhaps the array should be wrapped in an object (since the object can be iterated just as well as the array). That's fine too, I'm just looking for an existing good-practice pattern.

Described problem looks very similar to usual linked list. You can just add next and prev fields into your object, or in case you don't want to change it, you can create a wrapper object which will contain the original and will have those fields. Or in case the array is global enough to store only your current index inside the array and then it's very simple to get your neighbors.

I'd consider using the Iterator interface with your wrapper object. This approach would be the "existing good practice" that you're looking for.

Depending on the version of PHP you are running, the SPL provides a SplDoublyLinkedList class that provides all the primary features of a doubly linked list.