
O co chodzi?
Ano mam coś takiego:
<? $cats = new cats(); $cats->GenerateArray(); class cats{ function __construct(){ 'id' => 1, 'name' => 'Realizacje', 'parent_id' => 0 ); ( 'id' => 2, 'name' => 'Wroc?aw', 'parent_id' => 1 ); ( 'id' => 3, 'name' => 'Realizacje 2', 'parent_id' => 2 ); ( 'id' => 4, 'name' => 'Polanica', 'parent_id' => 0 ); ( 'id' => 5, 'name' => 'Podkategoria 3', 'parent_id' => 3 ); ( 'id' => 6, 'name' => 'PodPodkategoria 4', 'parent_id' => 5 ); $this->cats = $array; } function GenerateArray($parent=0, $level=0, $prefix=''){ foreach ($this->cats as $item){ if ($item['parent_id']==$parent){ if($item['parent_id']==0) 'name'=>$item['name'], 'parent_id'=>$item['parent_id'], ); 'name'=>$item['name'], 'parent_id'=>$item['parent_id'], ); $this->ids2[] = $item['id']; $this->GenerateArray($item['id'],$level+1, $space); } } } } } }
i chcę, aby $this->CArray miał strukturę:
$this->CArray[ID] = (
['name'] => nazwa kategorii
'childs'=> array()//tutaj mają być "dzieci" kategorii
);
Czyli żeby powstało coś takiego:

Pozdrawiam!
problem jest z tym, żeby zagnieżdżał się w zmiennej $CArray