Parsing Large Files
The method above works well for relatively simple files, but what if you need to parse a large file with a basic structure that has a few subtle variations? One method is to use the ereg() function[1] to seek out patterns of data.
This next script parses a large text file and places its contents into a database. The file is a list of 789 multiple-choice questions that appear on the FAA's private-pilot written exam.[2]
[2] The questions are not under copyright and are freely available.
The document follows a basic structure, in that it has numbered questions followed by three possible answers. Some of the questions reference a figure, while other questions reference multiple ...
Get Advanced PHP for Web Professionals now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.