Read ()) {if ($file! = '. ') && $file! = ' ... ') {Searchdir ($path. ') /'. $file, $data); }} $DP->close (); } if (Is_file ($path)) {$data []= $path;}} function Getdir ($dir) {$data =array (); Searchdir ($dir, $data); return $data;}? >
After the method executes, an array of file names is returned, and the output is traversed:
$list =getdir (' image '); for ($i =0; $i
'; }
Output Result:
From the way can be seen that the file name contains the path we specified, if only to get the file name, only need to Getdir ($dir) with a for loop to handle it,
Add the following code to the return before you can:
for ($i =0; $i
Also if your file name is in Chinese and is garbled, change the encoding to gb2312.
The above describes the PHP get the file name of all the files under the specified folder, including the contents of the content, I hope the PHP tutorial interested in a friend helpful.