//Define an array to store the results after deduplication
$result = array();
//Read uid list file
$fp = fopen('test.txt', 'r');
while(!feof($fp))
{
$uid = fgets($fp);
$uid = trim($uid);
$uid = trim($uid, "r");
$uid = trim($uid, "n");
if($uid == '')
{
continue;
}
//Us uid as key to see if the value exists
if(empty($result[$uid]))
{
$result[$uid] = 1;
}
}
fclose($fp);
//Save results to file
$content = '';
foreach($result as $k => $v)
{
$content .= $k."n";
}
$fp = fopen('result.txt', 'w');
fwrite($fp, $content);
fclose($fp);
?>
//Define an array to store the results after deduplication
$result = array();
//Read the first uid list file and put it into $result_1
$fp = fopen('test_1.txt', 'r');
while(!feof($fp))
{
$uid = fgets($fp);
$uid = trim($uid);
$uid = trim($uid, "r");
$uid = trim($uid, "n");
if($uid == '')
{
continue;
}
//Write $result with uid as key, if there are duplicates, they will be overwritten
$result[$uid] = 1;
}
fclose($fp);
//Read the second uid list file and perform duplication operation
$fp = fopen('test_2.txt', 'r');
while(!feof($fp))
{
$uid = fgets($fp);
$uid = trim($uid);
$uid = trim($uid, "r");
$uid = trim($uid, "n");
if($uid == '')
{
continue;
}
//Us uid as key to see if the value exists
if(empty($result[$uid]))
{
$result[$uid] = 1;
}
}
fclose($fp);
//The result saved in $result is the result after deduplication, which can be output to a file and the code is omitted
?>