Thus far, most of the examples you've seen have dealt with individual files. However, you often find yourself faced with the task of iterating over one or more directories and processing the file list within each. In order to meet this requirement, PHP offers a comprehensive set of directory manipulation functions, which allow developers to read and parse an entire directory listing. In order to demonstrate, consider the following simple example, which lists all the files in the directory "/bin":
You can combine the script above with the getcwd() function discussed earlier to obtain a list of all the files in the current working directory at any time - I'll leave that to you to try out for yourself.
blog comments powered by Disqus |