I have a big json file containing an array of objects. The file is too big (15MB) to be parsed by json_decode. How could I split this array-file into multiple array-files?
The array contains objects, which may also contain objects within it.
I have a big json file containing an array of objects. The file is too big (15MB) to be parsed by json_decode. How could I split this array-file into multiple array-files?
The array contains objects, which may also contain objects within it.
you can try array chunking -
$halved_array = array_chunk($original_array, ceil(count($original_array)/2));
You can't chuck the file without having the whole string in memory at any time. You may need to work on the source of the problem (if you can) instead of trying to deal with it. However you can setup a cron than will have for only job to chuck this JSON file into multiple JSON files.