PHP 获取多个 URL 内容并自动换行
可以通过使用 PHP 的 file_get_contents 函数和 foreach 循环来实现获取多个 URL 的内容并自动换行。
示例代码:
<?php
$urls = array(
'http://example.com/page1.php',
'http://example.com/page2.php',
'http://example.com/page3.php'
);
foreach ($urls as $url) {
$content = file_get_contents($url);
echo $content . "\n"; // 自动换行
}
?>
在上面的代码中,我们首先定义了一个包含多个 URL 的数组 $urls。然后,我们使用 foreach 循环遍历每个 URL,并使用 file_get_contents 函数获取其返回的内容。最后,我们将内容输出到屏幕上,并在每个 URL 的内容之间添加了一个换行符。
请注意,如果您的服务器不支持 file_get_contents 函数,请使用 curl 或其他相关函数来替代。
原文地址: https://www.cveoy.top/t/topic/mtSy 著作权归作者所有。请勿转载和采集!