I m writing a recursive function to construct a multidimensional array. Basically, the problem is as follows:
function build($term){
$children = array();
foreach ( $term->children() as $child ) {
$children[] = build($child);
}
if(!count($children)){
return $term->text();
} else {
return $term->text() => $children; //obviously, this doesn t work
}
}
Thoughts? I know I could rewrite the structure of the function to make it work, but it seems like that should be unnecessary.