The first user submitted response in this php manual entry warrants further study.
Monthly Archives: March 2015
Store array to file as JSON String
The accepted answer to this StackOverflow question shows how to save multiple json strings to a text file.
Directory structure to nested array
Here is an interesting method for creating a nested array based on the directory structure of a list of URLs.