Linked Questions

25 questions linked to/from create array tree from array list
110 votes
11 answers
77k views

I have a bunch of name-parentname pairs, that I'd like to turn into as few heirarchical tree structures as possible. So for example, these could be the pairings: Child : Parent H : G F : G ...
Eric's user avatar
  • 98.1k
0 votes
2 answers
258 views

I am at a little bit of a loss as to how to approach this, I suspect foreach is not the right answer, and I am aware of the existence of array_walk() and RecursiveArrayIterator, but I have no real-...
Little Code's user avatar
  • 1,575
-1 votes
1 answer
275 views

I have a multidimensional associative array "$nav_menus" looks like this: Array ( [0] => Array ( [id] => 1 [menu_name] => Media [parent_id] => 0 [...
Hazem_M's user avatar
  • 587
0 votes
1 answer
44 views

There is the following array. $arrTmp = array(); $arrTmp = array( array('id' => 206, 'BoardName' => 'Schedule', 'pid' => 196), array('id' => 145, 'BoardName' => '...
김동원's user avatar
0 votes
0 answers
26 views

I'm currently assigned to task in which I will need to group raw array data. The data is very simple and it has root_id to determine the parent of the element. The task is to group it dynamically ...
55 votes
14 answers
75k views

I've looked around the internet and haven't quite found what I'm looking for. I have a flat array with each element containing an 'id' and a 'parent_id'. Each element will only have ONE parent, but ...
DSkinner's user avatar
  • 593
5 votes
2 answers
1k views

I'm using PHP and I need help with a seemingly simple task with an array. This is my example array: $arr = array( 0 => NULL, 1 => NULL, 2 => NULL, 3 => NULL, 8 =&...
2 votes
1 answer
3k views

I have category table: CategoryID CategoryName ParentID 1 Root Null 2 News 1 3 Horoscope 1 4 Sports ...
CodeManiac's user avatar
  • 1,004
-3 votes
5 answers
2k views

I have an array: $data_array = array( array('id'=> 1 , 'parent_id' => 1 , 'name'=>'Air Vehicles' ), array('id'=> 2 , 'parent_id' => 2 , 'name'=>'Land Vehicles' ), ...
Nasir Jamal's user avatar
0 votes
1 answer
2k views

Here is my array output Array ( [1] => Array ( [id] => 1 [name] => Category A [parent] => 0 ) [2] => Array ( ...
user1286499's user avatar
0 votes
1 answer
1k views

So I am planning to create a dynamic organizational chart, can anyone give me a hint on how can I design my database? Org chart is something like image on the link below. Sorry for my bad drawing ...
MarkP.'s user avatar
  • 11
1 vote
1 answer
380 views

I want to make a select tree for my category. Here is for unordered list. function generate_menu($parent, $menu_array = null) { $has_childs = false; foreach ($menu_array as $key => $value) ...
0 votes
1 answer
1k views

I am currently working on a project that requires me to take an uploaded spreadsheet file (XLSX, XLS, etc), place it into an array, then based off of the parent child relationship, build an HTML table ...
0 votes
2 answers
685 views

I'm trying to develop a hierarchical menu in my e-commerce website in which my categories are dynamically shown in order to add more categories without having to touch the code. So I've organized my ...
1 vote
1 answer
498 views

I have $categories variable returns the following JSON data. I'd like to build a Tree->Branches in Php from this variable. Any idea? +Public - Electonics .....- Computer ........+ iPad-Tablets .....+...

15 30 50 per page
1
2