I have to read a file, parse out the contents, and compare them to values in a database.
The file is a text file with no delineation. I have a info sheet that tells me length and position of each field in the file.
So basically it's like this:
1A234Boole June
The first character for length of 1 is the type. The 2-5 characters are identifier, and the next 6 characters are last name... etc.
I've attempted using file_get_contents, but when I put in more than 2 parameters it gives me the error "Warning: file_get_conents() expects at most 2 parameters, 3 given". Even while PHP.net says "file_get_contents() returns the file in a string, starting at the specified offset up to maxlen bytes". My server is running PHP 4.3.2-RC3-dev.. or so the php.ini file says. Maybe I just don't understand file_get_contents.
So, what is the best way to do this? Should I use fgets() to get a line, and then use substr to get at each bit of data within the line? Assign it to an array then compare to the DB.. then do it again with the next line?
I'd appreciate any help I can get.
Thanks.
Edit.. oh, and the second line is a different layout than the first. They data comes in two-line blocks.