php mysql百万级数据去除重复数据 |
时间:2015-01-23 来源:西部数据 作者:西部数据 |
|
- <?php
-
- $result = array();
-
- $fp = fopen('test.txt', 'r');
-
- while(!feof($fp))
- {
- $uid = fgets($fp);
- $uid = trim($uid);
- $uid = trim($uid, " ");
- $uid = trim($uid, " ");
-
- if($uid == '')
- {
- continue;
- }
-
- if(emptyempty($result[$uid]))
- {
- $result[$uid] = 1;
- }
- }
-
- fclose($fp);
-
-
- $content = '';
- foreach($result as $k => $v)
- {
- $content .= $k." ";
- }
- $fp = fopen('result.txt', 'w');
- fwrite($fp, $content);
- fclose($fp);
- ?>
-
-
- <?php
-
- $result = array();
-
- $fp = fopen('test_1.txt', 'r');
- while(!feof($fp))
- {
- $uid = fgets($fp);
- $uid = trim($uid);
- $uid = trim($uid, " ");
- $uid = trim($uid, " ");
- if($uid == '')
- {
- continue;
- }
-
- $result[$uid] = 1;
- }
- fclose($fp);
-
- $fp = fopen('test_2.txt', 'r');
- while(!feof($fp))
- {
- $uid = fgets($fp);
- $uid = trim($uid);
- $uid = trim($uid, " ");
- $uid = trim($uid, " ");
- if($uid == '')
- {
- continue;
- }
-
- if(emptyempty($result[$uid]))
- {
- $result[$uid] = 1;
- }
- }
- fclose($fp);
-
- ?>
|
|
|
|