<?php
//读取
$content = file_get_contents('test.txt');
//分割数组
$arr = explode("\n", $content);
$str = "";
$tmp = "";
for ($i = 0; $i < count($arr); $i++)
{
$str = str_replace('1', 'ABC', $arr[$i]);
//拼接
$str = str_replace(array("\r","\n"," "),"", $str);
$tmp .= $str;
}
//写入
if (file_put_contents("test.txt", trim($tmp)))
{
echo "OK";
}
?>
PHP_txt文本替换
最新推荐文章于 2022-12-09 00:59:06 发布