活见鬼,为什么这个内置函数这样写不行
见鬼,为什么这个内置函数这样写不行?
- PHP code
<!-- Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighlighter.com/ -->$path = 'E:/Zl/资料-1/资料库/3005 奥迪A6L新型C6原厂资料'; function get_filetree($path){ $tree = array(); foreach(glob($path."/{*.pdf,*.doc,*.ppt}", GLOB_BRACE) as $single){ if(is_dir($single)){ $tree = array_merge($tree,get_filetree($single)); } else{ $tree[] = $single; } } return $tree; } print_r(get_filetree($path));
把{*.pdf,*.doc,*.ppt} 换成 * 就可以显示所有文件了,目录有些文件....
------解决方案--------------------
这样写
- PHP code
function get_filetree($path){ $tree = array(); foreach(glob($path."/*.{pdf,doc,ppt}", GLOB_BRACE) as $single) { if(is_file($single)) $tree[] = $single; } foreach(glob($path."/*", GLOB_ONLYDIR ) as $single) { $tree = array_merge($tree,get_filetree($single)); } return $tree; } <br><font color="#e78608">------解决方案--------------------</font><br> 你#6的写法也是可以的,但用错了目标<br>if(glob($path."*/*.{pdf,doc,ppt}", GLOB_BRACE)){<br>应为<br>if(glob($single."{pdf,doc,ppt}", GLOB_BRACE)){<br>目的是判断 $single 的后缀是否符合要求<br><br>我#4的代码:<br> //取得所有符合条件的文件名<br> foreach(glob($path."/*.{pdf,doc,ppt}", GLOB_BRACE) as $single) {<br> if(is_file($single)) $tree[] = $single;<br> }<br> //遍历所有子目录<br> foreach(glob($path."/*", GLOB_ONLYDIR ) as $single) {<br> $tree = array_merge($tree,get_filetree($single));<br> }<br> <div class="clear"> </div>

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

How to set the PATH environment variable in Linux systems In Linux systems, the PATH environment variable is used to specify the path where the system searches for executable files on the command line. Correctly setting the PATH environment variable allows us to execute system commands and custom commands at any location. This article will introduce how to set the PATH environment variable in a Linux system and provide detailed code examples. View the current PATH environment variable. Execute the following command in the terminal to view the current PATH environment variable: echo$P

Method to set the path environment variable: 1. Windows system, open "System Properties", click the "Properties" option, click "Advanced System Settings", in the "System Properties" window, select the "Advanced" tab, and then click "Environment Variables" " button, find and click "Path" to edit and save; 2. For Linux systems, open the terminal, open your bash configuration file, add "export PATH=$PATH: file path" at the end of the file and save it; 3. For MacOS system, the operation is the same as above.

tree is a command line tool that recursively lists the contents of a directory in a tree format, so that all directories, subdirectories, and files are listed in a hierarchical manner, thereby visually displaying the organizational structure of files and folders. The following are the installation and use methods of tree under Windows and Linux systems. The installation and use of tree under Linux. Installing tree under Linux: aptupdate&&aptinstalltree The following are the common ways of using the tree command. #Display the directory tree under the specified path tree/d/temp #Limit the maximum display depth tree-L3 #Display only directories but not files tree-d #Display including hidden files and directories tr

php提交表单通过后,弹出的对话框怎样在当前页弹出php提交表单通过后,弹出的对话框怎样在当前页弹出而不是在空白页弹出?想实现这样的效果:而不是空白页弹出:------解决方案--------------------如果你的验证用PHP在后端,那么就用Ajax;仅供参考:HTML code

How to correctly set the PATH environment variable in Linux In the Linux operating system, environment variables are one of the important mechanisms used to store system-level configuration information. Among them, the PATH environment variable is used to specify the directories in which the system searches for executable files. Correctly setting the PATH environment variable is a key step to ensure the normal operation of the system. This article will introduce how to correctly set the PATH environment variable in Linux and provide specific code examples. 1. Check the current PATH environment variable and enter the following command in the terminal

Configuration steps: 1. Find the Java installation directory; 2. Find the system environment variable settings; 3. In the environment variable window, find the variable named "Path" and click the edit button; 4. In the pop-up edit environment variable window , click the "New" button, and enter the Java installation path in the pop-up dialog box; 5. After confirming that the input is correct, click the "OK" button.

"The Role and Importance of the PATH Environment Variable in Linux" The PATH environment variable is one of the very important environment variables in the Linux system. It defines which directories the system searches for executable programs. In the Linux system, when the user enters a command in the terminal, the system will search one by one in the directories listed in the PATH environment variable to see if the executable file of the command exists. If found, it will be executed. Otherwise, "commandnotfound" will be prompted. The role of the PATH environment variable: Simplified

Python is a powerful programming language that is widely used in data analysis, web development and other fields. In file operations, it is often necessary to match file names or file paths based on specific patterns. Python provides the glob module for file pattern matching. This article will introduce how to use the glob module for file pattern matching in Python2.x. The glob module is part of the Python standard library and can be used without additional installation. It provides pattern based string
