码迷,mamicode.com
首页 > Web开发 > 详细

php file取重复

时间:2015-05-23 11:22:35      阅读:124      评论:0      收藏:0      [点我收藏+]

标签:

function FetchRepeatMemberInArray($array) {
// 获取去掉重复数据的数组
$unique_arr = array_unique ( $array );
// 获取重复数据的数组
$repeat_arr = array_diff_assoc ( $array, $unique_arr );
return $repeat_arr;
}

<?php
$words = file(‘zong.txt‘);
$tems = file(‘guolv.txt‘);
$complete_arr = array();
$jieguo = array();
$complete = ‘‘;
foreach($words as $word) {
$word = trim($word);
foreach($tems as $tem) {
$tem = trim($tem);
if($word == $tem){
echo $word.‘!=‘.$tem."</br>";
$jieguo[] = $word;
}
}
}

foreach($jieguo as $item) {
$complete .= $item . "\r\n" ;
}

file_put_contents(‘complete.txt‘, $complete);
echo "OK";

php file取重复

标签:

原文地址:http://www.cnblogs.com/alex-13/p/4523758.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!