当前位置:网站首页>PHP processing tree and infinite processing
PHP processing tree and infinite processing
2022-06-11 06:16:00 【Results of persistence and effort】
/**
* Merging of arrays , And plus html Identification prefix
* @param array $data
* @param int $pid
* @param string $html
* @param int $level
* @return array
*/
public function treeLevel(array $data, $pid = 0, $html = '---', $level = 0) {
static $arr = [];
foreach ($data as $val) {
if ($pid == $val['pid']) {
// How many times to repeat a character
$val['html'] = str_repeat($html, $level * 2);
$val['level'] = $level + 1;
$arr[] = $val;
$this->treeLevel($data, $val['id'], $html, $val['level']);
}
}
return $arr;
}
/**
* Data Multilevel
* @param array $data
* @param int $pid
* @return array
*/
public function subTree($data, $pid = 0) {
// The result returned
$arr = [];
foreach ($data as $val) {
// A given PID Is the superior of the current record ID
if ($pid == $val['pid']) {
// recursive
$val['sub'] = $this->subTree($data,$val['id']);
$arr[] = $val;
}
}
return $arr;
}边栏推荐
- Delegation agreement, data source agreement and advanced view in view
- Observer mode (listener mode) + thread pool to realize asynchronous message sending
- Sqli-libs post injection question 11-17 actual combat
- MATLAB realizes mean filtering and FPGA for comparison, and uses Modelsim waveform simulation
- Installing MySQL for Linux
- ERROR 1215 (HY000): Cannot add foreign key constraint
- Shandong University machine learning experiment 7 pca+ SVM face recognition
- Don't be afraid of xxE vulnerabilities: understand their ferocity and detection methods
- 数组部分方法
- [daily exercises] merge two ordered arrays
猜你喜欢

Shandong University machine learning experiment 5 SVM

箭头函数的this指向

亚马逊、速卖通、Lazada、虾皮平台在用911+VM的环境可以进行产号、养号、补单等操作吗?

FPGA面试题目笔记(四)—— 序列检测器、跨时钟域中的格雷码、乒乓操作、降低静动态损耗、定点化无损误差、恢复时间和移除时间

Detailed steps for installing mysql-5.6.16 64 bit green version

Thymeleafengine template engine

Transfer Learning

Simple understanding of pseudo elements before and after

做亚马逊测评要了解的知识点有哪些?

View controller and navigation mode
随机推荐
Stock K-line drawing
ERROR 1215 (HY000): Cannot add foreign key constraint
Yonghong Bi product experience (I) data source module
FPGA interview notes (III) -- implementation of handshake signal synchronization in cross clock domain, arbitrary frequency division, binary conversion, RAM memory, original code inversion and complem
Array partial method
Set the IP address using batch
Cenos7 builds redis-3.2.9 and integrates jedis
Eureka集群搭建
Free get | full function version of version control software
Moteur de modèle de moteur thymeleaf
Data quality: the core of data governance
数组部分方法
A multi classification model suitable for discrete value classification -- softmax regression
Simple knapsack problem
我们真的需要会议耳机吗?
[daily exercise] 217 Duplicate element exists
Login and registration based on servlet, JSP and MySQL
Do we really need conference headphones?
jenkins-不同风格的项目构建
Compliance management 101: processes, planning and challenges