Hi, Have a look at: http://www.box.net/shared/fdyp2h2yrp
It includes a recursive function you could use to build your tree. Thanks Dan On 13 May 2010 10:51, shahrzad khorrami <shahrzad.khorr...@gmail.com> wrote: > > hi all, > > I want to create an array from another array to create json file in my > format and pass it to a js library....ok. > I just know that I have to use recursive function... but how? it's hard for > me to create the new array.. > > main array: > > Array > ( > [0] => Array > ( > [nid] => 1 > [parentID] => 0 > [text] => Dashboard > [cls] => x-btn-icon > [icon] => lib/extjs/resources/images/default/icon/Dashboard.png > [singleClickExpand] => 1 > [leaf] => 0 > [id] => Dashboard > ) > > [1] => Array > ( > [nid] => 2 > [parentID] => 1 > [text] => Dashboard > [cls] => firstExpanded > [icon] => lib/extjs/resources/images/default/tree/s.gif > [singleClickExpand] => 1 > [leaf] => 0 > [id] => > ) > > [2] => Array > ( > [nid] => 3 > [parentID] => 2 > [text] => Dashboard > [cls] => x-btn-icon > [icon] => lib/extjs/resources/images/default/tree/s.gif > [singleClickExpand] => 1 > [leaf] => 1 > [id] => dashboard > ) > ........... > > > ---------------------- The array I want to create: ---------------- > > [0] => Array > ( > [nid] => 1 > [parentID] => 0 > [text] => Dashboard > [cls] => x-btn-icon > [icon] => lib/extjs/resources/images/default/icon/Dashboard.png > [singleClickExpand] => 1 > [leaf] => 0 > [id] => Dashboard > [children] => Array( > [0] => Array > ( > [nid] => 2 > [parentID] => 1 > [text] => Dashboard > [cls] => firstExpanded > [icon] => > lib/extjs/resources/images/default/tree/s.gif > [singleClickExpand] => 1 > [leaf] => 0 > [id] => > [children] => Array( > [0] => Array > ( > [nid] => 3 > [parentID] => 2 > [text] => Dashboard > [cls] => x-btn-icon > [icon] => > lib/extjs/resources/images/default/tree/s.gif > [singleClickExpand] > => 1 > [leaf] => 1 > [id] => dashboard > ) > ) > ) > ) > ) > > ......... > wow! > it means that by nid and parentID, I'll notice where I must add children > item to array... > > Thanks, > Shahrzad > > > >