关于php文件查找每一行的字符串与指定文件中的每一行的字符串
来源:互联网 发布:郑州网络诈骗最新新闻 编辑:程序博客网 时间:2024/05/16 01:42
<?php
//文件查找每一行的字符串与指定文件中的每一行的字符串比较
function ratherFile($file,$paper){
$handle = fopen($file, "r");
$handleTwo = fopen($paper, "r");
while (!feof ($handle))
{
$buffer = fgets($handle);
$username = trim($buffer);
rewind($handleTwo);
while (!feof ($handleTwo)){
$bufferTwo = fgets($handleTwo);
$userTwo = trim($bufferTwo);
if($username==$userTwo){
echo $username."<br/>";
break;
}
}
}
fclose ($handleTwo);
fclose ($handle);
}
$fileOne = dirname(__FILE__)."/bad.txt";
$fileTwo = dirname(__FILE__)."/ok.txt";
ratherFile($fileOne,$fileTwo);
//文件查找每一行的字符串与指定文件中的每一行的字符串比较
function ratherFile($file,$paper){
$handle = fopen($file, "r");
$handleTwo = fopen($paper, "r");
while (!feof ($handle))
{
$buffer = fgets($handle);
$username = trim($buffer);
rewind($handleTwo);
while (!feof ($handleTwo)){
$bufferTwo = fgets($handleTwo);
$userTwo = trim($bufferTwo);
if($username==$userTwo){
echo $username."<br/>";
break;
}
}
}
fclose ($handleTwo);
fclose ($handle);
}
$fileOne = dirname(__FILE__)."/bad.txt";
$fileTwo = dirname(__FILE__)."/ok.txt";
ratherFile($fileOne,$fileTwo);
阅读全文
1 0
- 关于php文件查找每一行的字符串与指定文件中的每一行的字符串
- 为文件的每一行后面添加特定字符串
- 为指定文本文件的的每一行的结尾添加指定字符串并写入新文件中
- c语言 读取文件的每一行; 查找指定key的value
- 9.11排序与查找(四)——20GB的文件,每一行一个字符串,说明如何将这个文件进行排序
- java读取文件夹下所有文件并替换文件每一行中指定的字符串
- 在一个文件中的每一行的指定列插入字符
- 反向读取文件的每一行
- shell读取文件每一行的方式
- shell读取文件的每一行
- shell读取文件的每一行
- shell读取文件的每一行
- shell读取文件的每一行
- shell读取文件的每一行
- Shell读取文件的每一行
- shell读取文件每一行的方式
- shell读取文件的每一行
- shell读取文件每一行的方式
- 获取地址栏
- 深度优先搜索 dfs Monk and Graph Problem
- MYSQL 查看最大连接数和修改最大连接数
- LeetCode【35】Search Insert Position
- HDU1251 统计难题(map)
- 关于php文件查找每一行的字符串与指定文件中的每一行的字符串
- CRM客户管理系统又翻天了
- git 使用
- 顺序存储链表
- 三星Android 4.4.x系统 java.lang.NoClassDefFoundError: com/google/firebase/FirebaseApp
- java IO流 之 转换流 v1.0.0
- 详解iframe与frame的区别
- LaTeX 入门资料整理
- 线程同步2 ------ 条件变量