数组中引用了三个文件$urls。在下面代码的循环中,links.xml仅写入其中一个文件。告诉我如何解决这种情况?
<?
preg_match_all("/(https\:\/\/www\.ikea\.com\/sitemaps\/prod-ru-RU\_[\d]+\.xml)/",
file_get_contents('https://www.ikea.com/sitemaps/sitemap.xml'), $urls);
$file = 'links.xml';
foreach ($urls[0] as $url) {
$threeFile = file_get_contents($url);
file_put_contents($file, $threeFile);
}
?>
为了不覆盖文件的内容,而是补充,您需要添加标志
FILE_APPEND:https://php.net/file-put-contents