This may work for you:
<?
$strDirectory = "/home/mkd/";
$DirHandle = opendir($strDirectory);
if ( $DirHandle )
{
// Get a list of files
while ($FileName = readdir( $DirHandle ) )
{
// Eliminate the root directories
if ( $FileName != "." & $FileName != "..")
{
// Add the file name to the array
$asFiles[] = $FileName;
echo $FileName . "<br>\n";
}
}
closedir( $DirHandle );
}
?>
Marcel wrote:
Sorry if this has been asked a million times but I need to know how to read the filenames from a folder into an array? I don't know how many files might be in there as it changes all the time. So I want to look into /temp and say there is file1.txt, file2.gif, file3.txt, file4.jpg and read the names into an array, say filenames[]? So filenames[0]=file1.txt, filenames[1]=file2.gif, filenames[2]=file3.txt, filenames[3]=file4.jpg. Any ideas?
Thanks in advance for all feedback.
Marcel.