php 无限级分类函数
ar=array(0=>array('name'=>'食物','id'=>1,'pid'=>0),
02 1=>array('name'=>'植物','id'=>2,'pid'=>0),
03 3=>array('name'=>'白菜','id'=>3,'pid'=>1),
04 4=>array('name'=>'树','id'=>4,'pid'=>2),
05 5=>array('name'=>'苹果','id'=>5,'pid'=>3),
06 6=>array('name'=>'松树','id'=>6,'pid'=>4),
07 7=>array('name'=>'饮料','id'=>7,'pid'=>1),
08 8=>array('name'=>'测试1','id'=>8,'pid'=>7),
09 9=>array('name'=>'测试2','id'=>9,'pid'=>8),
10 10=>array('name'=>'人民','id'=>10,'pid'=>9),
11 11=>array('name'=>'小米','id'=>11,'pid'=>0),
12 );
13
14 echo '
17
18 function tre($tree,$id)
19 {
20 $str = '';
21 $strid = '';
22 foreach ($tree as $key => $item)
23 {
24 if ($item['pid'] == $id) {
25 $i = 0;
26 $i = sonNum($tree,$item['id']);
27 if ($i == 1 || $i == 0) {
28 echo '
29 } else {
30 echo '
31 }
32 //echo '
33 echo $item['name'];
34 echo '
35 tre($tree,$item['id']);
36 }
37 }
38 //tre($tree,$strid);
39 }
40
41 function sonNum($tre,$sum,$totale=1)
42 {
43 foreach ($tre as $key => $value)
44 {
45 if ($value['pid'] == $sum){
46 $totale += sonNum($tre,$value['id'],1);
47 }
48 }
49 return $totale;
50 }

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics











Multiple calls to session_start() will result in warning messages and possible data overwrites. 1) PHP will issue a warning, prompting that the session has been started. 2) It may cause unexpected overwriting of session data. 3) Use session_status() to check the session status to avoid repeated calls.

The Ouyi Exchange app supports downloading of Apple mobile phones, visit the official website, click the "Apple Mobile" option, obtain and install it in the App Store, register or log in to conduct cryptocurrency trading.

Sesame Open Door is a platform that focuses on cryptocurrency trading. Users can obtain portals through official websites or social media to ensure that the authenticity of SSL certificates and website content is verified during access.

AI can help optimize the use of Composer. Specific methods include: 1. Dependency management optimization: AI analyzes dependencies, recommends the best version combination, and reduces conflicts. 2. Automated code generation: AI generates composer.json files that conform to best practices. 3. Improve code quality: AI detects potential problems, provides optimization suggestions, and improves code quality. These methods are implemented through machine learning and natural language processing technologies to help developers improve efficiency and code quality.

session_start()iscrucialinPHPformanagingusersessions.1)Itinitiatesanewsessionifnoneexists,2)resumesanexistingsession,and3)setsasessioncookieforcontinuityacrossrequests,enablingapplicationslikeuserauthenticationandpersonalizedcontent.

Visit Binance official website and check HTTPS and green lock logos to avoid phishing websites, and official applications can also be accessed safely.

HTML5 brings five key improvements: 1. Semantic tags improve code clarity and SEO effects; 2. Multimedia support simplifies video and audio embedding; 3. Form enhancement simplifies verification; 4. Offline and local storage improves user experience; 5. Canvas and graphics functions enhance the visualization of web pages.

MySQL functions can be used for data processing and calculation. 1. Basic usage includes string processing, date calculation and mathematical operations. 2. Advanced usage involves combining multiple functions to implement complex operations. 3. Performance optimization requires avoiding the use of functions in the WHERE clause and using GROUPBY and temporary tables.
