Blogger Information
Blog 87
fans 0
comment 0
visits 59250
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
第七章:2、目录的遍历(上)
黄忠倚的博客
Original
824 people have browsed it

实例

<?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>';
}

运行实例 »

点击 "运行实例" 按钮查看在线实例


Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post