다차원 배열을 생성하는 재귀 함수를 작성하고 있습니다. 기본적으로 문제는 다음과 같습니다.배열없이 php 키 - 값 쌍의 인스턴스 만들기
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
}
}
생각 하시겠습니까? 함수의 구조를 다시 작성하여 작동하도록 만들 수 있지만 필요없는 것처럼 보입니다.
불행히도 데이터 유형이 인라인되지 않기를 바랍니다. 이것은 CodeIgniter의 ul()에 대한 입력입니다. http://codeigniter.com/user_guide/helpers/html_helper.html#ol_and_ul을 참조하십시오. – user199085