Dear list.
I want to compare two text files and print the differences. The text files
contain the structure of a database, so they are very big (>6000 lines).
The file looks like that:
TABLENAME#COLUMNNAME#DATATYPE#DATALENGTH#DATAPRECISION#NULLS
...
I only check if the datatype and nulls are different. If so, then the two
lines of the files will be printed.
I tried to do that and it works excellent if there aren't many differences,
but if there are many diffs, it takes time and time.
What I do now is to read the to files to an array and get the differences
with array_diff
$array1=file('file1.txt');
$array2=file('file2.txt');
$result1 = array_diff($array1,$array2);
$result2 = array_diff($array2,$array1);
After that I do the following:
foreach ($result1 as $line1) {
foreach ($result2 as $line2) {
// compare the two lines and show the differences;
continue;
}
}
Is there a better way to do that (and of course faster)?
Regards
Jens
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php