Load each file into a string array (using file_get_contents, for example).
Perform some loops that, for every item in array 2, determine if the item exists in array 1. If so, remove the item from array 2 and continue.
When complete, array 2 will contain only unique lines.
Edit:
If you just want to remove lines in File2 that are also present in File1, you're looking for the unique values (where order does not matter). A quick way to do this is using the array_diff function.
Here is an example:
$file1 = array('Mango', 'Orange', 'Cherry', 'Apple', 'Blackberry');
$file2 = array('Apple', 'Orange', 'Mango', 'Banana', 'Cherry', 'Blackberry');
$diff = array_diff($file2, $file1);
var_dump($diff);
// Output
array
3 => string 'Banana' (length=6)
If you prefer to do this manually using loops like I mentioned in the first part, here is how you would do it:
// Loop over every value in file2
for($i = count($file2) - 1; $i >= 0; $i--)
{
// Compare to every value in file1; if same, unset (remove) it
foreach($file1 as $v)
if ($v == $file2[$i])
{
unset($file2[$i]);
break;
}
}
// Reindex the array to remove gaps
$output = array_values($file2);
var_dump($output);
// Output
array
0 => string 'Banana' (length=6)