Last active
October 27, 2015 02:50
-
-
Save jslim89/34d2770610191f9200c7 to your computer and use it in GitHub Desktop.
Revisions
-
jslim89 revised this gist
Oct 27, 2015 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -7,7 +7,7 @@ * @access public * @return array */ function array_multi_level($menu_items, $depth = 1) { $items = array(); $in_current_depth = true; @@ -21,7 +21,7 @@ function ginota_menu_array_multi_level($menu_items, $depth = 1) { if ($in_current_depth && $item->level > $depth) { $in_current_depth = false; $item_left = array_slice($menu_items, $key); @$items[$key - 1]->children = array_multi_level($item_left, $item->level); } } -
jslim89 revised this gist
Aug 4, 2014 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,4 @@ <?php /** * Refer: https://stackoverflow.com/questions/14961556/convert-one-dimensional-array-into-a-multi-dimensional-array/14963016#14963016 * -
jslim89 renamed this gist
Aug 4, 2014 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
jslim89 renamed this gist
Aug 4, 2014 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
jslim89 created this gist
Aug 4, 2014 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,28 @@ /** * Refer: https://stackoverflow.com/questions/14961556/convert-one-dimensional-array-into-a-multi-dimensional-array/14963016#14963016 * * @param mixed $menu_items * @param int $depth * @access public * @return array */ function ginota_menu_array_multi_level($menu_items, $depth = 1) { $items = array(); $in_current_depth = true; foreach ($menu_items as $key => $item) { if ($item->level < $depth) return $items; else if ($item->level == $depth) { $in_current_depth = true; $items[] = $item; } if ($in_current_depth && $item->level > $depth) { $in_current_depth = false; $item_left = array_slice($menu_items, $key); @$items[$key - 1]->children = ginota_menu_array_multi_level($item_left, $item->level); } } return $items; }