当前位置:网站首页>PHP infinite classification (recursive)
PHP infinite classification (recursive)
2022-04-21 07:54:00 【Mars Murong】
public function Tree($arr, $pid = 0, $level = 0)
{
static $list = [];
foreach ($arr as $key => $value) {
if ($value["pid"] == $pid) {
$value["level"] = $level;
$list[] = $value;
unset($arr[$key]); // Delete the data that has been arranged in order to reduce the number of iterations , Of course, recursion itself is very troublesome
$this->Tree($arr, $value["id"], $level + 1);
}
}
return $list;
}
版权声明
本文为[Mars Murong]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204210629261939.html
边栏推荐
- Bluetooth open source protocol stack btstack summary
- 物联网操作系统Zephyr(入门篇)之1.0 Zephyr简介
- .net core 将错误抛出写入.txt文件
- When deploying. Net core on Linux platform to access SQL Server 2008 R2, it prompts the connection timeout exception
- 2022-04-20:小团去参加军训,军训快要结束了, 长官想要把大家一排n个人分成m组,然后让每组分别去参加阅兵仪式, 只能选择相邻的人一组,不能随意改变队伍中人的位置, 阅兵仪式上会进行打分,其中
- Common SQL
- 服务器部署svn环境
- C# WebService 接口 通过Request请求获取json参数
- URL Parsing
- PHP 对象转数组
猜你喜欢

Fuzzy query between two tables of SQL server and steps of importing Excel data into SQL Server

Record the problems and solutions encountered in using fastjson message converter

云原生KubeSphere实战多租户系统实战

343. Find the product of decomposed integers and maximize integer break

Leetcode title -- 386 Dictionary rank, DFS

服务器部署svn环境

pip list 中已有的模块为什么没法在新project中使用,已解决

“产业数字化”的技术背景与现实作用

Creating Oracle database in Navicat tool

Introduction to zephyr 1.0 of Internet of things operating system zephyr (Introduction)
随机推荐
Steps for umlet beginners
Unity性能优化之UI
STM32系统和自定义bootloader的实现和应用
When deploying. Net core on Linux platform to access SQL Server 2008 R2, it prompts the connection timeout exception
Base64 Encoding
Leetcode 704 · binary search
动态规划定点突破 --leetcode题目64.最小路径和
Panic and Recover
php 判断是不是同一个月
leetcode 206. Reverse linked list
Introduction to QT 5.12 actual combat
asp.net js 实现动态添加文件上传
服务器部署svn环境
php base64加密
Flutter first experience
Bluetooth Profile Specification之(AVRCP篇)5.1AVCTP的连接和释放
[image fusion] image fusion based on curvelet transform (evaluation index), including Matlab source code
Annotation function supplement
网关与分布式id
An entity class maps a field