file出这两个文件,进行比较,相同的就取一个,然后写入另一个文件中。
解决方案 »
- 如何用PHP,不断刷新页面中一小块div的内容?
- 网络聊天室系统
- 隐藏标单的用法
- 我一直觉得PHP不适合oop,不知道各位怎么看
- 在线支付安全问题 (加分)
- 控制数据表中数据量
- 这是?????Fatal error: Maximum execution time of 30 seconds exceeded in E:\webdata\managerinfo.php on line 195
- php设置问题
- 如何在php中向oracle数据库插入日期时间型数据?
- php echo $_post["name"]取不到数据但是echo $_POST可以去到完整的数据
- 关于mysql与php的数据读取问题的新手问题,大家都来讨论!!!
- 为什么 php3.0 以后的版本,addslashes不能去掉特殊字符 / 等
$data1=explode("\r\n",$txt_data1);
$data2=explode("\r\n",$txt_data2);
for($i=0;$i<count($data1);$i++){
for($f=0;$f<count($data2);$f++){
if($data1[$i]==$data2[$f]){
$temp="";
}else{
$temp=$data1[$i];
}
}
if($temp!="") $get_datas.=$temp."\r\n";
}
return $get_datas;
}
这是我目前写的,我知道一定是错的,相同的取一个怎么操作?
$file_b=file("b.txt");
for($i=0;$i<count($file_a);$i++){
if(!in_array($file_a[$i],$file_c){
$file_c[$i]=$file_a[$i];
}
}
$k=count($file_c);
for($j=0;$j<count($file_b);$j++){
if(!in_array($file_b[$j],$file_c){
$file_c[$k]=$file_b[$j];
k++;
}
}
$file_d=fopen("c.txt","a+");
for($i=0;$i<count($file_c);$i++){
fwrite($file_d,$file_d[$i]."\n");
}
-------------------
[email protected]
[email protected]
[email protected]
-------------------
[email protected]
[email protected]
[email protected]
-------------------
function savefile()
{
$a = file('a.txt');
$b = file('b.txt');
$arr1 = array_merge($a,$b);
$arr2 = array_unique($arr1);
Return $arr2;
}
print_r(savefile());