PHP: Building an Adjacency List through Recursive Iteration
问题 I'm trying to build a flattened array that preserves metadata from a pretty tricky array coming from a view in my CodeIgniter project. That metadata is things like an identifier, depth, and parent node. The data is from a query builder JavaScript library that allows a user to generate rules that will be used in business logic. I need to persist this data, and the model I've gone with to represent the tree-like nature of these rules is an adjacency list. Here's what I have, and it does work