I have a menu table:
id, slug, label, parent
Parent has a relation to id so if you had:
1, 'foo-bar', 'Foo Bar', NULL
This would be a root item whereas:
2, 'foo', 'Foo ', 1
Would belong to 'foo-bar'. Then you could have items belonging to foo and so on.
How can I turn this into a multi-dimensional menu array in PHP? So I can do things like:
<?= $menu['foo-bar']['foo'] // echos 'Foo' ?>
My requirements are very similar to How to convert DB table with parent son relation to multi-dimensional array but the answer there doesn't work; it isn't recursive.