不多说,直接上代码。txt.txt是插入前的文件,cp.txt是插入后的文件。
<?php
$handle = fopen("txt.txt", "r");
$h=fopen("cp.txt","w+");
if ($handle) {
while (!feof($handle)) {
$buffer2 = fgets($handle);
$buffer = preg_replace('/((\s)*(\n)+(\s)*)/i','',$buffer2);
$s = "cp ".$buffer.".htm ../sports/";
fwrite($h,$s."\r\n");
echo $s;
}
fclose($handle);
fclose($h);
}
?>
星期三, 07/23/2014 - 14:06 — 杨超