I would like to ask php how to traverse the specified local folder, and then splice it into a tree json for front-end use, because I want to make it into a tree table, thank you!

I don"t know how to spell the parentid and children fields of the node. Please give me an idea or plan. Thank you.

Php
Mar.06,2021

gives you an idea. Many people like to use recursion to solve problems, but if it is a folder, this is ridiculous. If I have 20 layers of files, do you want to use scandir to get them recursively? It certainly won't work like this. A good solution is to click on the directory and get the structure in the directory. In this way, the pressure will not be great. In this way, it is relatively easy for you to write the interface, you only need to get one layer. There are parent_id and children. Of course, it's not impossible for you to use recursion to get everything. Let the user wait a little longer. If there are too many files, wait until the end of time


give it a try:

$directory = '/directory';
$scanned_directory = json_encode(array_diff(scandir($directory), array('..', '.')));
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b37dd1-2c0bd.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b37dd1-2c0bd.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?