当前位置:网站首页>PHP recursive multi-level classification, infinite classification
PHP recursive multi-level classification, infinite classification
2022-06-30 14:19:00 【Meimei Technology】
function getChild($data, $id = 0)
{
// Initialize son
$child = [];
// Cycle all data to find $id Son
foreach ($data as $key => $datum) {
// I found my son
if ($datum['pid'] == $id) {
// preserved , Then continue to find his son's son
$child[$datum['id']] = $datum;
// Get rid of yourself first , You can't be your own grandchildren
unset($data[$key]);
// Recursively look for , And put the found son in a child In the field of
$child[$datum['id']]['child'] = $this->getChild($data, $datum['id']);
}
}
return $child;
}
From the Internet, thanks for sharing . Keep it for future use
边栏推荐
- QQ 居然被盗了?原因在这......
- "As a service", the inevitable choice of enterprise digital transformation
- 从控制层返回到js的json数据带“\”转译符,怎么去掉
- 深入理解.Net中的线程同步之构造模式(二)内核模式4.内核模式构造物的总结
- Getting started with shell Basics
- Go common lock mutex and rwmutex
- I'd like to ask you, where can I open an account in Foshan? Is it safe to open a mobile account?
- MySQL back to table query optimization
- Jetpack compose for perfect screen fit
- C language & the difference between the address pointed to and the address pointed to by the pointer
猜你喜欢
深入理解.Net中的线程同步之构造模式(二)内核模式2.内核模式构造物Semaphone
Flat shading with unity
Attack and defense world web questions
Tencent two sides: @bean and @component are used on the same class. What happens?
【科学文献计量】外文文献及中文文献关键词的挖掘与可视化
重磅:国产IDE发布,由阿里研发,完全开源!
go time. after
Apache Doris comparison optimization Encyclopedia
XSS challenge (1-5) more detailed answers
IM即时通讯应用开发中无法解决的“顽疾”
随机推荐
@Role of ResponseBody
@component使用案例
Race of golang
[scientific research data processing] [basic] category variable frequency analysis chart, numerical variable distribution chart and normality test (including lognormal)
步骤详解 | 助您轻松提交 Google Play 数据安全表单
Unity animator parameter
Notes on reverse learning in the first week of winter vacation
Pytorch查看模型参数量和计算量
Attack and defense world web questions
Initial attack and defense world Misc
Step by step | help you easily submit Google play data security form
Heavyweight: the domestic ide was released, developed by Alibaba, and is completely open source!
Small exercise of process and signal
Numpy creates an empty array data = np empty(shape=[1, 64,64,3])
【刷题篇】供暖器
Why is the resolution of the image generated by PHP GD library 96? How to change it to 72
Error on datetime when importing SQL file from MySQL
[observation] as the intelligent industry accelerates, why should AI computing power take the lead?
想请教一下,我在佛山,到哪里开户比较好?手机开户是安全么?
"Persistent diseases" that cannot be solved in IM application development