码迷,mamicode.com
首页 > Web开发 > 详细

php 文件夹遍历俩种对比

时间:2014-09-12 10:10:53      阅读:246      评论:0      收藏:0      [点我收藏+]

标签:io   for   文件   sp   cti   代码   on   c   amp   

configu.php
index.php
新建文件夹



D:\xampp\htdocs\1test\use\useversion/configu.php
D:\xampp\htdocs\1test\use\useversion/index.php
D:\xampp\htdocs\1test\use\useversion/mmmmmmmmmmm/configu2222222222222.php



D:\xampp\htdocs\1test\use\useversion/configu.php
D:\xampp\htdocs\1test\use\useversion/index.php
D:\xampp\htdocs\1test\use\useversion/mmmmmmmmmmm/configu2222222222222.php
D:\xampp\htdocs\1test\use\useversion/新建文件夹


代码:

<?php
function getDir($dirname) {
global $num;
$dh = opendir($dirname);
while (($file = readdir($dh)) !== false) {

if($file != ‘.‘ && $file != ‘..‘) {
if(is_dir($dirname . $file . ‘/‘))
getDir($dirname . $file . ‘/‘);
else {echo $file.‘<br/>‘;}
}}}
getDir("./useversion");
echo "<hr/>";

?>

<?php
function myscandir($pathname){

foreach( glob($pathname) as $filename ){

if(is_dir($filename)){
myscandir($filename.‘/*‘);
}else{
echo ‘<br>‘. $filename;
}
}
}

myscandir(‘D:\xampp\htdocs\1test\use\useversion‘);
echo "<hr/>";
?>
<?php

function myscandir2($path){

$mydir=dir($path);

while($file=$mydir->read()){
$p=$path.‘/‘.$file;
if((is_dir($p)) AND ($file!=".") AND ($file!="..")){
myscandir2($p);
}
if(($file!=".") AND ($file!="..")){
echo ‘<br>‘. $p;
}


}
}
myscandir2(‘D:\xampp\htdocs\1test\use\useversion‘);
echo "<hr/>";
?>

 

php 文件夹遍历俩种对比

标签:io   for   文件   sp   cti   代码   on   c   amp   

原文地址:http://www.cnblogs.com/alex-13/p/3967742.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!