I need to correct something in a lot of html documents.
So, i have a structure like this in my body (simplified) :
<body>
<div id="inter">
<!-- some content -->
</div>
</body>
I need to insert something just before the close tag of my div id="inter". I have to make use of PHP and DOMDocument I guess.
So I get something like:
<body>
<div id="inter">
<!-- some content -->
@insert something here
</div>
</body>
In my <div id="inter">, I can have a lot of content, like other div, image, span, etc.
Do you know how can I do that?
You can do this with
createElement()andappendChild():Demo: http://codepad.viper-7.com/GMGjkd
If you want to add a comment you can simply use the following:
Demo: http://codepad.viper-7.com/QMuDMt