4
I는 I 중첩 세트의 배열을 생성하기 위해이 함수를 발견이 spacetree 1)
http://blog.thejit.org/wp-content/jit-1.0a/examples/spacetree.html
위한 JSON로 내 중첩 세트 구조 (MySQL의) 변환해야
: 2) http://semlabs.co.uk/journal/converting-nested-set-model-data-in-to-multi-dimensional-arrays-in-php을
또한 PHP 함수로 json_encode와 JSON에
내 문제를 PHP 배열로 변환 할 수 있습니다 : (두 번째 링크에서) 기능 nestify을 제공 나를 정확히 내가 필요. 다음과 같은 것이 필요합니다. http://pastebin.com/m68752352
올바른 배열을 제공하도록 "nestify"기능을 변경할 수 있습니까? 다음 코드는 트릭을 할해야
function nestify($arrs, $depth_key = 'depth')
{
$nested = array();
$depths = array();
foreach($arrs as $key => $arr) {
if($arr[$depth_key] == 0) {
$nested[$key] = $arr;
$depths[$arr[$depth_key] + 1] = $key;
}
else {
$parent =& $nested;
for($i = 1; $i <= ($arr[$depth_key]); $i++) {
$parent =& $parent[$depths[$i]];
}
$parent[$key] = $arr;
$depths[$arr[$depth_key] + 1] = $key;
}
}
return $nested;
}
아무도 말해 줄 수 무엇 예를 들어,'$ stack [] = & $ trees [$ i];' –
'은 스택에 트리 항목의 참조를 저장한다. 그것). 자세한 내용은 PHP 매뉴얼의 [References Explained] (http://php.net/manual/en/language.references.php) 장을 참조하십시오. – wimvds
중요한 것. 이 함수를 사용하려면'left_id'에 의해'collection'의 주문 항목을 적용해야합니다 (중첩 된 세트 구조의 서비스 필드입니다). – userlond