Php 从包含链接的文本文件的每一行中删除换行符,并在iframe中显示这些链接 $myFile=“text.txt”; $lines=文件($myFile); $link1=$lines[0]; $link2=$lines[1];

Php 从包含链接的文本文件的每一行中删除换行符,并在iframe中显示这些链接 $myFile=“text.txt”; $lines=文件($myFile); $link1=$lines[0]; $link2=$lines[1];,php,Php,将您的线路更改为: $myFile = "text.txt"; $lines = file($myFile); $link1 = $lines[0]; $link2 = $lines[1]; <!-- 1 --> <iframe src="<?php echo $link1?>" width="100%" height="50" frameborder="0" scrolling="no"> your browser do not support

将您的线路更改为:

$myFile = "text.txt";
$lines = file($myFile);

$link1 = $lines[0];
$link2 = $lines[1];

<!-- 1 -->
<iframe src="<?php echo $link1?>" width="100%" height="50" frameborder="0" scrolling="no">
    your browser do not support iframes.</iframe>

<!-- 2 -->
<iframe src="<?php echo $link2?>" width="100%" height="50" frameborder="0" scrolling="no">
    your browser do not support iframes.</iframe>

使用此标志,每行末尾的新行将删除

您可能需要从链接变量中修剪“行尾”。它对行有效,谢谢!但iframe仍然没有加载我不知道为什么,它显示拒绝连接。尝试在浏览器中打开开发者控制台,可能有一些提示。
$lines = file($myFile, FILE_IGNORE_NEW_LINES);