Vanilla 1.1.4 is a product of Lussumo. More Information: Documentation, Community Support.
<?php
$handle1 = @fopen("inputfile1.txt", "r"); //open file for read
while (!feof($handle1)) { // continue check the file end
$line1 = fgets($handle1); //read the line from file
$handle2 = @fopen("inputfile2.txt", "r");
while (!feof($handle2)){
$line2 = fgets($handle2);
if($line1 == $line2){
$filename = 'thirdfile.txt';
$somecontent = $line1;
if (is_writable($filename)) {// Let's make sure the file exists and is writable first.
if (!$handle3 = fopen($filename, 'a')) {//file open in append mode to add text on new line
echo "Cannot open file ($filename)";
exit;
}
if (!fwrite($handle3, $somecontent)) {
echo "Cannot write to file ($filename)";
exit;
}
echo "Success, wrote ($somecontent) to file ($filename)<br>";
fclose($handle3);
} else {
echo "The file $filename is not writable";
}
}
}
fclose($handle2);
}
fclose($handle1);
?>
1 to 3 of 3