That should get you started :
$dirname='/var';
$dh=opendir($dirname) or die('could not open directory');
while (!(($file=readdir($dh))===false)){
if (is_dir('$dirname/$file')){
$myarray[]=$file;
}
echo "$file";
$myarray[]=$file;
}
Mario
Merlin wrote:
Hi there,
does anybody know h
Example 2. List all files in the current
> directory and strip out . and ..
>
> if ($handle = opendir('.')) {
>while (false !== ($file = readdir($handle))) {
>if ($file != "." && $file != "..") {
>echo "$file\n"
mply strip them out: Example 2. List all files in the current
directory and strip out . and ..
-Original Message-
From: Merlin [mailto:[EMAIL PROTECTED]
Sent: 01 April 2005 12:32
To: php-general@lists.php.net
Subject: [PHP] getting filenames from dir
Hi there,
does anybody know ho
Try this function:
function scandir($dirstr){
$files = array();
$fh = opendir($dirstr);
while (false !== ($filename = readdir($fh))){
array_push($files, $filename);}
closedir($fh);
return $files;
}
return an array with all th
Hi there,
does anybody know how to get all file names from a specified directory into an
array?
Thanx,
Merlin
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
5 matches
Mail list logo