<?php
//文件查找每一行的字符串与指定文件中的每一行的字符串比较
function ratherFile($file,$paper){
$handle = fopen($file, "r");
$handleTwo = fopen($paper, "r");
while (!feof ($handle))
{
$buffer = fgets($handle);
$username = trim($buffer);
rewind($handleTwo);
while (!feof ($handleTwo)){
$bufferTwo = fgets($handleTwo);
$userTwo = trim($bufferTwo);
if($username==$userTwo){
echo $username."<br/>";
break;
}
}
}
fclose ($handleTwo);
fclose ($handle);
}
$fileOne = dirname(__FILE__)."/bad.txt";
$fileTwo = dirname(__FILE__)."/ok.txt";
ratherFile($fileOne,$fileTwo);
//文件查找每一行的字符串与指定文件中的每一行的字符串比较
function ratherFile($file,$paper){
$handle = fopen($file, "r");
$handleTwo = fopen($paper, "r");
while (!feof ($handle))
{
$buffer = fgets($handle);
$username = trim($buffer);
rewind($handleTwo);
while (!feof ($handleTwo)){
$bufferTwo = fgets($handleTwo);
$userTwo = trim($bufferTwo);
if($username==$userTwo){
echo $username."<br/>";
break;
}
}
}
fclose ($handleTwo);
fclose ($handle);
}
$fileOne = dirname(__FILE__)."/bad.txt";
$fileTwo = dirname(__FILE__)."/ok.txt";
ratherFile($fileOne,$fileTwo);