Originally posted by StevenSm
Thanks for your reply.
The file is about 4,000 lines long..The only problem with this code is that the script would need to compare Line 1 of file B with all 4,000 lines in file A, and Line 2 of file B with 4,000 lines, etc...
It seems like this would take a long time to process, but maybe that's the only way it can be done..
Well, since you want to compare each line of file B with every line in file A, then you would have to do something like that.
This is where a proper database would be a lot more useful than a plain text file, because then the files you store the data in would be much better organised and also indexed to speed tasks such as this up.
In this case, you could read both files in as arrays of individual entries, with the entries in a comparable form (so you can tell if a line in B is also in A with a simple == test), and then use some combination of array algebra functions ([man]array_diff[/man], [man]array_intersect[/man], [man]array_merge[/man], for example) to get (elements of B that are in A), (elements of B that are not in A...), (elements of A that are in 😎 etc., and merge the appropriate bits back together. The result might need to be resorted afterward depending on whether the order in which entries appear in the file is important.