我完全摸不着頭腦,其中甚至開始在這一點,但我需要提供關鍵字列表中的文件A,然後在同一名單B.合併兩個文本文件用PHP - foreach循環
有了這些過文件,我想在foreach線上線追加在文件B
例如:
文件:
一號線
2號線
3號線
文件B:
test1的
test2的
TEST3
輸出到combined.txt文件:
line1test1
line2test1
line3test1
line1test2 ...等等
如果您可以提供我要研究的部分腳本,一個示例腳本,甚至是一個工作國王的方式來做到這一點。我將不勝感激。
每請求,這是我的示例代碼:
<?php
$file1 = 'keywords.txt';
$file2 = 'topics.txt';
$combined = 'combined.txt';
$keywords = fopen("keywords.txt", "rb");
$topics = fopen("topics.txt", "rb");
$front = explode($topics);
$back = explode($topics);
while (!feof($keywords)) {
file_put_contents($combined, . $front ."". $back . "\n");
fclose($keywords & $topics);
}
?>
您需要提供代碼示例以證明您至少已經嘗試過。 – jeremyjjbrown