A technique for processing large text files in PHP without running into memory limits or timeouts. The approach splits file parsing into chunks using start and max-line parameters, then uses HTTP redirects (header Refresh) combined with PHP sessions to reload the same script with updated offsets — effectively resetting memory and timeout between chunks. A working code example demonstrates reading a tab-delimited file line by line, processing only the relevant chunk per run, and looping until the entire file is parsed.

3m read timeFrom patrickbrosset.com
Post cover image

Sort: