Iterating over a nested menu isn’t that easy, especially when we got a big menu with many nested levels. The problem that I want to solve here is to build an unordered HTML list that is based on a multi-level nested menu for our products: I will be using the SPL library to solve this problem. SPL provides a bunch of iterators, In this post I will be using both RecursiveArrayIterator as well as RecursiveIteratorIterator. As its name implies, the RecursiveArrayIterator iterates over a given array, but it doesn’t support nested arrays, therefore we also need to use the RecursiveIteratorIterator. Let’s get started: The RecursiveIteratorIterator class has four methods that will react when a particular event occurs, these methods are: beginIteration, endIteration, beginChildren and endChildren.