Anybody know of a ready-made php class which can read a file-system directory recursively (including all files and sub-directories) and return an array or object or JSON string or XML of the structure?
I would do this myself but a client just called and is insisting on it being done today. Yay.
You can make use of the in-build
RecursiveDirectoryIteratorDocs class to create your wished outcome. In the following example an hierarchical array is created:$arraywill then contain the listing:Using
json_encodeDocs can simple turn this into something like:As I’ve written in a comment above,
globcan be useful, too.