Home >Backend Development >PHP Tutorial >资料比较有没有重复

资料比较有没有重复

WBOY
WBOYOriginal
2016-06-13 10:51:401191browse

文件比较有没有重复?
比较2个txt文件里面的每行数据有没有重复.
如:
1.txt

808274 826542267532
829575 417850170591
968784 677512546053
994943 395284907536
212236 485276124525


2.txt

010653 641973541583
976885 972087709626
980109 759921215816
649015 043755572655
031179 843814920390

如上所示,首先判断1.txt和2.txt里面的每行数据是否有重复,
然后再判断1.txt和2.txt所有的数据加起来有没有重复?

------解决方案--------------------
最简单的方法是把两个文件都读入数组,然后用array_diff

Statement:
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