Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

An example Analysis of implementing Index Tree according to the average Daily reference

Shulou Source: shulou.com Published: 2022-06-02 11:06:23 10月04日 Update

This article mainly introduces the example analysis of the daily average index tree according to the reference, which has a certain reference value, and interested friends can refer to it. I hope you will gain a lot after reading this article. Let the editor take you to know it.

$array = array (0 = > array ('id'= > 1pyrrhenium)), 2 = > array (' id'= > 3MYRIMUIDOID = > 1primer menus = > 1 submenu menus urlations = > 0)), 1 = > array ('id'= > 2precepts = > 0menus), 1 = > menus = > 2menus = > 0menus = > 0menus = > 0menus 3 = > array ('addtime'= >' 2018-08-29 16 purl 3615 55'), 3 = > array ('id'= > 4 recordings menunameplates = > 3 memorials = > 1 sub-menus 2 minute codes addtimepieces = > 0 camera addtimepieces = >' 2018-08-29 16 VR 36 rigs 55'), 4 = > array ('id'= > 5 parcels menunamees = > 2 submenus 1 minutes title urlations = > 0 minutes urlums = > 2018-08-29 16 purport 3655'),) Function getTree ($items,$pid = "uid") {$map = []; $tree = []; foreach ($items as & $it) $map [$it ['id']] = & $it; / / the ID name of the data generates a new reference index tree foreach ($items as $k = > & $at) {$parent = & $map [$at [$pid]; if ($parent) {$parent [' children'] [] = & $at } else {$tree [] = & $at;}} return $tree;} print_r (getTree ($array)); die

The effect is

Array ([0] = > Array ([id] = > 1 [uid] = > 0 [menuname] = > menu 1 [url] = > 0 [addtime] = > 2018-08-29 16:36:55 [children] = > Array ([0] = > Array) ([id] = > 3 [uid] = > 1 [menuname] = > 1 submenu 1 [url] = > 0 [addtime] = > 2018-08-29 16:36:55 [children] = > Array ([0] = > Array ([id] = > 4) [uid] = > 3 [menuname] = > 1 submenu 2 [url] = > 0 [addtime] = > 2018-08-29 16:36:55 )) [1] = > Array ([id] = > 2 [uid] = > 0 [menuname] = > menu 2 [url] = > 0 [addtime] = > 2018-08 -29 16:36:55 [children] = > Array ([0] = > Array ([id] = > 5 [uid] = > 2 [menuname] = > 2 submenu 1 [url] = > 0 [addtime] = > 2018-08-29 16:36:55) Thank you for reading this article carefully I hope the article "sample Analysis of Index Tree based on reference" shared by the editor will be helpful to everyone. At the same time, I also hope that you will support and pay attention to the industry information channel, and more related knowledge is waiting for you to learn!

Tags: Menus articles indexes examples analysis value interests at the same time effects data more friends knowledge editing industry information information channels channels references learning Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Tech Info Xiaomi vpn macOS Docker