PHP 动态添加 html 代码到 html 文件

PHP Dynamically add html code to html file

我正在寻求帮助将 html 代码动态添加到 html 文件。

这是我想添加到文件中的示例:

<a rel="lightbox[acc1]" href="myimage.jpg" title="myimage"/>

我想将其附加到使用灯箱的堆栈[acc1] element/function, 我最好使用 PHP 来执行此操作,因为我将使用 sessions/cookies 带有页面管理员的图片链接。

如有任何帮助,我们将不胜感激。

干杯, 杰夫

将您的 html 文件设为 php 文件并执行此操作:

<?php echo "<a rel=\"lightbox[acc1]\" href=\"myimage.jpg\" title=\"myimage\"/>" ?>

您的 html 文件必须是 php 文件或 html 可以执行 php 然后您可以 运行 foreach 语句来完成它。

foreach($_POST['acc1'] as $image){

   echo "<a rel=\"lightbox[acc1]\" href=\"" . $image . "\" title=\"myimage\"/>"


}