• 冒险村物语
  • 英雄无敌3塔防
  • 驾考家园手游

php 遍历目录

2014-09-05

1. [代码]php 遍历目录方法1    
01 <?php

02  

03     function myscandir($pathname){

04  

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

06  

07             if(is_dir($filename)){

08                 myscandir($filename.'/*');

09             }else{

10                 echo $filename.'<br/>';

11             }

12         }

13     }

14     

15     myscandir('D:/wamp/www/exe1/*');

16  

17 ?>

2. [代码]php 遍历目录方法2    
01 <?php

02  

03     function myscandir($path){

04  

05         $mydir=dir($path);

06  

07         while($file=$mydir->read()){

08             $p=$path.'/'.$file;

09         

10             if(($file!=".") AND ($file!="..")){

11             echo $p.'<br>';

12             }

13         

14             if((is_dir($p)) AND ($file!=".") AND ($file!="..")){

15                 myscandir($p);

16             }

17         }  

18     }

19  

20     myscandir(dirname(dirname(__FILE__)));

21     

22 ?>

 

(免责声明:文章内容如涉及作品内容、版权和其它问题,请及时与我们联系,我们将在第一时间删除内容,文章内容仅供参考)

人气推荐

知识阅读

精彩推荐

  • 游戏
  • 软件
查看更多>>