PHP mysql millions data deduplication _php Tutorial

Source: Internet
Author: User
Tags php mysql
Defines an array for storing the result after the row
$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
}
Use UID as key to see if the value exists
if (Empty ($result [$uid])
{
$result [$uid] = 1;
}
}

Fclose ($FP);

Save the results to a file
$content = ";
foreach ($result as $k = $v)
{
$content. = $k. " n ";
}
$fp = fopen (' Result.txt ', ' W ');
Fwrite ($fp, $content);
Fclose ($FP);
?>


Defines an array for storing the results after a row
$result = Array ();
Read the first UID list file and put $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 key, overwrite if duplicate
$result [$uid] = 1;
}
Fclose ($FP);
Read the second UID list file and perform a sort of a load 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
}
Use UID as key to see if the value exists
if (Empty ($result [$uid])
{
$result [$uid] = 1;
}
}
Fclose ($FP);
$result saved in the following the result of the weight can be output to the file, code omitted
?>

http://www.bkjia.com/PHPjc/630861.html www.bkjia.com true http://www.bkjia.com/PHPjc/630861.html techarticle PHP Tutorial//Define an array to hold the result after the row $result = Array ();//Read UID list file $fp = fopen (' test.txt ', ' R '), while (!feof ($fp)) {$uid = FGE TS ($FP); $ui ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.