Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

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

2025-01-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report