[PHP] Directory Listing in an Array

2001-08-20 Thread Chris Aitken

Hey all,

Just something I havent been able to sort out in the archives, but what im 
wanting to do it this. Do a listing of all files in a directory, and load 
up an array with each returned filename.

Am I pissing into a windy pipe dream or is there a simple solution for this ?



Cheers


Chris


--
 Chris Aitken - Administration/Database Designer - IDEAL Internet
  email: [EMAIL PROTECTED]  phone: +61 2 4628   fax: +61 2 4628 8890
  __-__
   *** Big Brother ***
It just shows that the dull will rule the world. And we will be watching it.


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Directory Listing in an Array

2001-08-20 Thread speedboy

 Just something I havent been able to sort out in the archives, but what im 
 wanting to do it this. Do a listing of all files in a directory, and load 
 up an array with each returned filename.

$files_dir = /tmp;
chdir($files_dir);
$dir_handle = @opendir($files_dir) or die(Unable to open $files_dir);
$files = array();
while ($file = readdir($dir_handle)) {
array_push($files, $file);
}
closedir($dir_handle);
sort($files);
reset($files);
for ($i = 0; $i  count($files); $i++) {
echo $files[$i] br;
}


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Directory Listing in an Array

2001-08-20 Thread Dallas K.

This is what I use


file://DIR to start looking in
$basedir = C:/Inetpub/wwwroot/_ActiveClientFiles/GLS/portfolio/;
file://working DIR or the dir to change to.
$wdir = web/;
// list of DIRs var
$dirlist;
$filelist;
$add_dir ;


/***
***
// Load Online Directorys

**/
chdir($basedir . $wdir.'online/');
file://open the dir
$online=opendir(.);

while ($files = readdir($online))
{ 
 if(is_dir($files)  ( $files !== .  $files !== .. ) )
 { 
  $online_dir[$files] = $files; file://add files
 }
}

if(count($online_dir))  file://sort
{ asort($online_dir); 
}
rewinddir($online);
closedir($online);



?
- Original Message - 
From: Chris Aitken [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Sent: Monday, August 20, 2001 8:05 PM
Subject: [PHP] Directory Listing in an Array


 Hey all,
 
 Just something I havent been able to sort out in the archives, but what im 
 wanting to do it this. Do a listing of all files in a directory, and load 
 up an array with each returned filename.
 
 Am I pissing into a windy pipe dream or is there a simple solution for this ?
 
 
 
 Cheers
 
 
 Chris
 
 
 --
  Chris Aitken - Administration/Database Designer - IDEAL Internet
   email: [EMAIL PROTECTED]  phone: +61 2 4628   fax: +61 2 4628 8890
   __-__
*** Big Brother ***
 It just shows that the dull will rule the world. And we will be watching it.
 
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]
 



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]