覆蓋txt文件內容:
$filename="aa/a.txt";
$handle=fopen($filename,"w");
$str=fwrite($handle,"test");
fclose($handle);
效果:
testtesttesttesttesttesttest
追加內容到txt:
$filename="aa/a.txt";
$handle=fopen($filename,"a+");
$str=fwrite($handle,"test\n");
fclose($handle);
效果:
test
test
test
test
test
test
test
逐行讀取txt:
$lines=file("db.txt");
foreach($lines as$value){
$line=explode(",",$value);
echo"no1:$line[0]--no2:$line[1]---time:$line[2]-<br>";
}
*