Turn database result into array

Okay, I’ve written PHP classes that extend the Zend Framework DB table, row, and rowset classes. I’ve been developing this anyway because I’m speaking at PHP Tek-X in a couple of weeks about hierarchical data models. I don’t want to post all my code to Stack Overflow because they implicitly get licensed under Creative Commons … Read more

Convert flat array to the multi-dimensional

I don’t think there is a built-in function in PHP that does this. I tried the following code, and it seems to work to prepare the nested array the way you describe: $nodes = array(); $tree = array(); foreach ($source as &$node) { $node[“Children”] = array(); $id = $node[“Menu”][“id”]; $parent_id = $node[“Menu”][“parent_id”]; $nodes[$id] =& $node; … Read more