Re: Appending into associative arrays

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



2007. 04. 16, hétfő keltezéssel 09.27-kor Otto Wyss ezt írta:
> Alister Bulman wrote:
> > 
> >>> $dirs[$d] = filemtime($d);
> >> Has he even retrieved the directories in sorted order by modification
> >> time? If not he still needs to sort.
> > 
> > Then he'll need an asort($dirs);  They would not have come in any
> > particular order, so you have to sort them for whatever you need
> > anyway.
> > 
> Fine. But how do I now implement recursive looking for directories? My 
> code doesn't work.

what do you mean by doesn't work? what error is thrown if any? what
result do you get instead of the expected?
at first glance I cannot see anything wrong with your function...

greets
Zoltán Németh

> 
>    function recurseDir ($base, $accending = true, $dirs = array()) {
>      $handle = opendir ($base);
>      while ($dir = readdir($handle)) {
>        if (($dir != '..') and ($dir != '.')) {
>          $d = $base.'/'.$dir;
>          if (is_dir ($d)) {
>            $dirs[$d] = filemtime($d);
>            recurseDir ($d, true, $dirs);
>          }
>        }
>      }
>      closedir ($handle);
>      asort ($dirs);
>      return array_keys ($accending? $dirs: array_reverse ($dirs));
>    }
> 
> O. Wyss
> 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux