I am writing a PHP script (to be run from command line) to parse hundreds of large JSON files. All of these files are in a directory. Initially I was reading the files one by one and parsing them in the same script, but ran out of memory quickly. The other way to do it is to have two scripts, one to read the directory, get the list of files and call another script with the file name to be parsed as arguments. Is there any other way to do it?
Also, is there any way to parallelize this?