简体   繁体   中英

PHP Dynamically add html code to html file

I am looking for help to dynamically add html code to a html file.

This is an example of what I would like to add to the file:

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

I would like to append this to the stack that uses the lightbox[acc1] element/function, and I would preferably like to do this with PHP as I wil be using sessions/cookies with the image links for page admins.

Any help on this would be appreciated.

Cheers, Jeff

使您的html文件成为php文件,然后执行以下操作:

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

You'd have to have your html file be a php file or html which can execute php and then you can run a foreach statement to do it.

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

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


}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM