ini_set('memory_limit', '-1'); //
ini_set("max_execution_time", "3600"); //设置超时时间
$filep='qq.txt';
$str=file('qq.txt');
$lineCount = 0;
foreach( $str AS $line ) {
$line = str_replace( "\t", " ", $line );
$tr = trim( $line );
if ( preg_match( "/\\*|^\*|^ {1,}\*|\/\*|\*\/|^ {1,}\/\/|^\/\//", $line ) || $tr === "" ) {
continue;
}
$lineCount++;
$line = str_replace( "\r", "", $line );
$line = str_replace( "\n", "", $line );
if($lineCount<5){
is_m('5.txt',"".$line."@qq.com\n");
continue;
}elseif ($lineCount <10){
is_m('10.txt',"".$line."@qq.com\n");
break;
}
}
function is_m($filename,$c){
$handle = fopen($filename, "a");
if ($handle) {
fwrite($handle, $c );
fclose($handle);
} }php 文件操作
最新推荐文章于 2024-04-19 00:15:00 发布
本文介绍了一段使用PHP进行文件读取、字符串处理及写入的具体实现方法。通过正则表达式过滤特定行,并将筛选后的数据按条件写入不同的文件中。此过程涉及了PHP内存限制与执行时间的设置、文件操作函数的应用等内容。
2295

被折叠的 条评论
为什么被折叠?



