覆盖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>"; }