douhuang9886 2014-12-07 19:46
浏览 24

使用Directory迭代器函数,我会得到不同的结果,具体取决于路径名和其他内容?

I am trying to read filenames from two directories. It works for one pathname but the other just gives me the files at the root (not the pathname I selected). So the first part gives the files under C:/TEMP/TEST but if fails to do so with the following directory; it just gives me the files located at C:/TEMPO and not C:TEMPO/TEST.

I am new to php, Thanks.

<?php

$dd = 0;
$ee = 0;
$HALLO1 = 'C:/TEMP/TEST';

foreach ($CC1 as $directory)  {
   //$DD1 = ($CC1[$dd]);
   $GG1 = strval($CC1[$dd]);
   $HALLO1 = $GG1;

   echo "HALLO1" . $HALLO1 ;
   $iterator = new DirectoryIterator(dirname($HALLO1));
   foreach ($iterator as $fileinfo) {

   echo $fileinfo->getFilename() . "
";
   $isidor[$ee] = $filename1;
   echo "isidor" .  $dd . $filename1 . "
"; 
 ++$ee;
  }


  $vv = 0;
 $ww = 0;
 $HALLO2 = 'C:/TEMPO/TEST';

 foreach ($CC2 as $directory2)  {

     $iterator = new DirectoryIterator(dirname($HALLO2));
 foreach ($iterator as $fileinfo) {

      echo $fileinfo->getFilename() . "
";
      $heli [$ww] = $filename2;
      echo "heli" .  $vv . $filename2 ;
   ++$ww;
  }

 ?>
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 matlab中使用gurobi时报错
    • ¥15 WPF 大屏看板表格背景图片设置
    • ¥15 这个主板怎么能扩出一两个sata口
    • ¥15 不是,这到底错哪儿了😭
    • ¥15 2020长安杯与连接网探
    • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
    • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
    • ¥16 mybatis的代理对象无法通过@Autowired装填
    • ¥15 可见光定位matlab仿真
    • ¥15 arduino 四自由度机械臂