I have a hierarchy or rooms and subrooms without a universal array mapping it out. Instead I connect the ids of parent to child. So I need to use a recursive php function to loop through subrooms of a room and the subrooms of each of those and on an on and then build an array of all their ids
If I were just going to output each id as a string, I'd do it like this
function get_all_child_subrooms_recursive($rid) {
$subrooms = get_all_subrooms($rid); // a function that grabs an array of direct children room id's to the parent room ($rid)
if ($subrooms == "") {
return;
} else {
foreach ($subrooms as $subroom) {
$rid = $subroom;
echo $rid .',';
get_all_child_subrooms_recursive($rid);
}
}
}
But I need this data returned as a flat array containing all the id's
get_all_subrooms()?