On Sunday 28 October 2007 15:37:21 Nathan Nobbe wrote:
> i suppose this is what youre looking for ?
> you can tailor it to your needs of course :)
>
> <?php
> $it = new RecursiveDirectoryIterator('.');
> $isFirstDir = true;
> $fileList = array();
> $dynfile = fopen('sortedFiles', 'w+');
> $theRecursiveIteratorIterator =
> new RecursiveIteratorIterator($it,
> RecursiveIteratorIterator::CHILD_FIRST);
>
> foreach ($theRecursiveIteratorIterator as $path){
> if($path->isDir()){
> /// drop the name of the directory into the results
> fwrite($dynfile, 'Directory: ' . (string) $path . PHP_EOL);
> if($isFirstDir) { // just update the flag on the
> first dir
> $isFirstDir = false;
> } else {
> sort($fileList); // sort the list however
> you like
> /// iterate over the sorted list, placing them in
> the output file
> foreach($fileList as $sortedDirFile) {
> fwrite($dynfile, $sortedDirFile . PHP_EOL);
> }
> $fileList = array(); // clear the list for the
> next directory
> }
> }else{ /// place the current path to a file in the list
> $fileList[] = (string) $path;
> }
> }
> fclose($dynfile);
> ?>
>
>
> -nathan
both yes and no.
Yes I can modify this 'n put it to good use, and no I'm stille buggered with
creating array just to print it again, when I could've writting it instead of
filling the array.
--
---
Børge Holen
http://www.arivene.net
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php