发布作者: 代码控
百度收录: 正在检测是否收录...
最后更新: 2024年 05月 22日 12:06
作品采用: 《 署名-非商业性使用-相同方式共享 4.0 国际 (CC BY-NC-SA 4.0) 》许可协议授权
<?php
// 读取文件内容
$file = '1.txt';
$content = file_get_contents($file);
// 按行拆分文本内容
$lines = explode("\n", $content);
// 保留包含特定文本的行
$filteredLines = array_filter($lines, function($line) {
return strpos($line, '蜘蛛池') !== false;
});
// 将筛选后的行重新组合成文本内容
$newContent = implode("\n", $filteredLines);
// 将新内容写回文件
file_put_contents($file, $newContent);
echo '文件处理完成。';
?>
—— 评论区 ——