<?php /医院 * 1.opendir(), readdir(), closedir() * 2.目录扫描器:scandir() */ //1.目录函数来实现 $dir = opendir('../0419') or die('打开失败'); while (false !=($file = readdir($dir))) { // print $file."<br>"; print $file."\n"; print nl2br($file."\n"); if ($file != ":" && $file != "...") { print nl2br($file."\n"); } } closedir($dir); echo '<hr>'; //2.scandir()将当前目录全部保存到一个数组中 $fileArr = scandir('.'); echo '<pre>'; print_r($fileArr); foreach ($fileArr as $key => $value) { echo '$file <br>'; }
点击 "运行实例" 按钮查看在线实例