In it's simplest form, I have a tree hierarchy in a MySQL database where every section has both a 'sectionID' and a 'parent', both numeric values.
My starting point will be an array of sectionID numbers, e.g. 2, 3, 5, 8, 13, 21, 34, 55 & 89 - but this could be much larger.
From this array, I want to go back up the tree on each until a certain parent is hit, say for example 144 (which isn't guaranteed).
From this I want to create two new arrays: -
1) Those sectionIDs from the original list where 144 is listed as a parent somewhere higher up the hierarchy and
2) Those where 144 doesn't feature higher up the tree
The depth is unknown, but I'd know the end is reached when parent is either not set or is equal to 1 or 0.
Any help would be greatly appreciated!