<?php
// files we will be using
$lfile = "iro.txt"; // file with the things that are in both files
$bfile = "kro.txt"; // file with the things that are in both files plus others
// open files into variables
$lopened = fopen("$lfile", "r");
$bopened = fopen("$bfile", "r");
// explode by "\n" (lines)
$lsplit = explode("\n","$lopened");
$bsplit = explode("\n","$bopened");
// close file since we already have their data
fclose($lopened);
fclose($bopened);
// fun variables we'll use
$a = 0;
$b = 0;
// write out the differences between the files
while($a <= sizeof($bsplit)) // search the entire $bfile
{
if($lsplit[$b] == $bsplit[$a]) // If a line appears in both files...
{
$a++; // go to next line in the $bfile
} else { // or if the line does not appear in the $lfile...
if($b == sizeof($lsplit)) // if the $lfile is at the last line...
{
echo "$bsplit[$a]\n"; // write out the line that we are on in the $bfile
$b = 0; // go back to the first line in $lfile
$a++; // go to the next line in $bfile
} else { // or if we are not on the last line of $lfile...
$b++; // go to the next line in $lfile
}
}
}
?>
(This uses no MySQL)
this code yields a Resource id #3. I have no idea what's wrong with it 😕
Thank you for any help.