For example, I want date in this format
Use format string "Y-m-d"
Here is a sample html file contains only "p" and "div" tag:
And we want to insert content into the html, we don't want undermine the html structure, we wish to delimit it in terms of html element, not just characters. We also want to know the positions we want to insert the content. We can use PREG_OFFSET_CAPTURE: