I want to compare two files to check whether the second file is modified from the first file.
For this implementation I have planned to compare the md5_file()
of the both files. But the problem is the original file is created by the Unix line coding and second file might be any type of line coding (Unix, Mac or Windows).
So the file compare always fails.
How to solve this issue?.
I have tried to remove the white spaces from the both files then proceeded the comparison. But this method also fails. Is there any other way to solve issue?
Im not supposed to copy or change the second file.
Fixed Myself as follows
$file1 = md5(preg_replace('/\s/', '', file_get_contents($file1)));
$file2 = md5(preg_replace('/\s/', '', file_get_contents($file2)));
if ($file1 == $file2)
continue;