[請益] 寫入txt檔的問題
讀取的txt檔內容如下
1
RE42,327
Medicinal compositions improving brain function and method for improving
brain function
2
RE42,325
Homogeneous multiplex hybridization analysis by color and Tm
-------------------------------------------------------------------------
程式碼如下,我希望把brain function跟前一行做合併再重新寫入txt檔
$handle = fopen('data.txt','r');
$fs = fopen('output.txt','w');
while(($buffer = fgets($handle))!==false)
{
$p=str_replace("/(\015\012)|(\015)|(\012)/"," ",$buffer);
$p=str_replace(",","",$buffer);
if(strlen($p)<=9)
{
fwrite($fs,$p);
}
else
{
$nexline = fgets($handle);
$t = str_replace("/(\015\012)|(\015)|(\012)/"," ",$nexline);
$t = str_replace(",","",$nexline);
if(strlen($t)<=9)
{
fwrite($fs,$p);
fwrite($fs,$t);
}
else
{
$s = $p.$t;
echo $s."<br>";
fwrite($fs,$s);
}
}
}
fclose($fs);
fclose($handle);
從網頁上顯示echo $s的結果是成功合併了,但是開啟寫入的txt檔發現還是被分割成兩
行(跟原先開啟的txt檔內容一樣), 請問問題出在哪呢?
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 58.115.110.27
※ 編輯: rutill6003 來自: 58.115.110.27 (05/06 18:58)
→
05/06 19:37, , 1F
05/06 19:37, 1F
→
05/06 20:01, , 2F
05/06 20:01, 2F
→
05/06 20:03, , 3F
05/06 20:03, 3F
→
05/06 20:06, , 4F
05/06 20:06, 4F
→
05/07 09:30, , 5F
05/07 09:30, 5F
推
05/08 12:31, , 6F
05/08 12:31, 6F
討論串 (同標題文章)