Re: Comparing 2 files

From: Date: Sun, 21 Mar 2004 22:45:30 +0000
Subject: Re: Comparing 2 files
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-181101@lists.php.net to get a copy of this message
Visit sourceforge and look for winmerge, a really excellent software that does just what you want. Thrust me - install this software and never look for anything else, :) Altleast if your on a windows environment. -- -- Kim Steinhaug ---------------------------------------------------------------------- There are 10 types of people when it comes to binary numbers: those who understand them, and those who don't. ---------------------------------------------------------------------- www.steinhaug.com - www.easywebshop.no - www.webkitpro.com ---------------------------------------------------------------------- "Jens Schmeiser" <hightower@hightower24.de> wrote in message news:KEEGJOKNOLCNIOJKEAAJCEBLCGAA.hightower@hightower24.de... > 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

« previous php.general (#181101) next »