看板 PHP 關於我們 聯絡資訊
$file = fopen("test.txt", "r"); //讀入 $file_w=fopen('output.txt', 'w');//寫入 while(! feof($file)) { $a = str_replace(' ', '',trim(fgets($file))."\n"); fwrite($file_w ,$a); } fclose($file); fclose($file_w); 若是要寫入同檔案 就必須先把內容讀完在寫入 不然沒辦法 順序要改成下面這樣 $file = fopen("test.txt", "r"); while(! feof($file)) { $a .= str_replace(' ', '',trim(fgets($file))."\n"); } fclose($file); $file_w=fopen('test.txt', 'w'); fwrite($file_w ,$a); fclose($file_w); -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 210.62.185.25 ※ 文章網址: https://www.ptt.cc/bbs/PHP/M.1421899072.A.DDA.html
powyo: 為什麼你的ip不是127.0.0.1 01/22 12:10
onininon: 推id 01/22 12:43
KawasumiMai: 請問本機,掃帚在哪? 01/23 10:55
ProfessUX: 這id XDDDDDD 帥到炸 01/23 20:49
xx250919: 謝謝幫助^^,已解決 01/24 19:15