php 遞歸遍歷目錄


<?php

header('Content-Type: text/html; charset=utf-8');
/**	
 * @param 目錄地址
 */
function readDirs($path) {
	$dir_handle = openDir($path);

	while(false !== $file=readDir($dir_handle)) {
		if ($file=='.' || $file=='..') continue;

		//輸出該文件
		echo $file, '<br>';
		//判斷當前是否為目錄
		if(is_dir($path . '/' . $file)) {
			//是目錄
			readDirs($path . '/' . $file);
		}

	}

	closeDir($dir_handle);
}

// $path = './';
// readDirs($path);

  


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM