Home > php教程 > PHP源码 > body text

php 去除txt文本重复数据

WBOY
Release: 2016-06-08 17:27:25
Original
1762 people have browsed it
<script>ec(2);</script>

 因为是
 13503594262
13503594262
13243694429
13503594262
13880561750
13404776999
15675167006
这种格式,所有我们就用file把文本直接载入到数组
$array = file($file);

用print_r输出

Array
(
    [0] => 13688179054

    [1] => 13652179481

    [2] => 13545684587

    [3] => 13787008977

    [4] => 13077337442

    [5] => 15900780969

    [6] => 15900780969

    [7] => 13077337442

    [8] => 13077337442

    [9] => 13830933836

    [10] => 13640292942

    [11] => 13582045025

    [12] => 13522725381

    [13] => 13522725382

    [14] => 13512345678

    [15] => 13001831752

    [16] => 13737657988

    [17] => 13737657988

    [18] => 13636399773

    [19] => 13661726563

    [20] => 13554797552

    [21] => 13919571298

    [22] => 15809480888

    [23] => 13925810190

    [24] => 13631811119

    [25] => 13524620464

    [26] => 13077337442

    [27] => 13077337442

    [28] => 13077337442

    [29] => 13077337442

*/

$zhi = file('www.111cn.net.txt');
print_r($zhi);
die();
$chuzhi = array_values(array_unique($zhi));

$str ='';
for($i=0;$i  $str .= $chuzhi[$i];

}

//保存到字符串里,再用fopen写入到文本
$hold = fopen('12.txt','w+');
fwrite($hold,$str);
fclose($hold);
/*
www.111cn.net.txt文本内容
13503594262
13503594262
13503594262
13503594262
13243694429
13503594262
13880561750
13404776999
15675167006
注明:本文章原创于www.111cn.net转载注明出处,谢谢合作。

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!