Jump to content

Insert HTML Code for all the pages in a directory


sachithd

Recommended Posts

To find out the full file name of the script you are running you can print the __FILE__ constant. You can use that info to figure out which path you need to give the script.To add something directly after the body tag, you need to find the position of wherever the body tag ends, then insert whatever you want at that point. You can use strpos to find the position of "<body", and then find the first ">" after that.

$bodystart = strpos($html, "<body");$bodyend = strpos($html, ">", $bodystart + 5) + 1;

Once you know where the body ends then you can get all the text before it and after it.

$start = substr($html, 0, $bodyend);$end = substr($html, $bodyend);

Once you have all the text before and including the body tag, and all the text after it, then you can insert whatever you want in between when you save the new file.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...