How would I read files from a certain directory? I've looked all over and I couldn't find anything.
Reading files from a directory
Started by derek.sullivan, Jul 07 2007 11:15 AM
2 replies to this topic
#1
Posted 07 July 2007 - 11:15 AM
#2
Posted 07 July 2007 - 12:40 PM
PHP Function read_dir
ALSO See your directory functions here!
Example to display files from a directory:
ALSO See your directory functions here!
Example to display files from a directory:
<?php
if ($handle = opendir('/path/to/files')) {
echo "Directory handle: $handle\n";
echo "Files:\n";
/* This is the correct way to loop over the directory. */
while (false !== ($file = readdir($handle))) {
echo "$file\n";
}
closedir($handle);
}
?>
Edited by Braunson, 07 July 2007 - 12:42 PM.
#3
Posted 07 July 2007 - 01:52 PM
Braunson, on Jul 7 2007, 01:40 PM, said:
PHP Function read_dir
ALSO See your directory functions here!
Example to display files from a directory:
ALSO See your directory functions here!
Example to display files from a directory:
<?php
if ($handle = opendir('/path/to/files')) {
echo "Directory handle: $handle\n";
echo "Files:\n";
/* This is the correct way to loop over the directory. */
while (false !== ($file = readdir($handle))) {
echo "$file\n";
}
closedir($handle);
}
?>Newest php has a function called, scandir. Which is what you have above.
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users
