On Sat, Jul 17, 2004 at 07:07:44PM -0600, C.F. Scheidecker Antunes wrote:
> 
> Is there a more efficient way to compare 2 TXT files other than reading 
> line by line ?
> 
> What I was doing was reading line by line and compare both files, if one 
> line is different the loops are interrupted and the function returns true.
> 
> Any ideas?

If all you're trying to do is determine whether the files are different,
and the files are relatively small, then it might be easiest to do
something like:

  function filediff($foo, $bar) {
    $f_foo = file_get_contents($foo);
    $f_bar = file_get_contents($bar);
    return ($f_foo == $f_bar);
  }

Note that this has the opposite return value of your existing function:
it returns true if the files are THE SAME, like the unix "diff" command.

Alternately, if you want to know what differences exist between files,
you could load the files into arrays with the file() function, then use
the array_diff() function to spit out a list of lines in one file but
not the other.

Or, you could tell us more about what you're actually trying to do.  :)

p

-- 
  Paul Chvostek                                             <[EMAIL PROTECTED]>
  Operations / Abuse / Whatever
  it.canada, hosting and development                   http://www.it.ca/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to