I have a problem, I am wanting to do the following but I cannot work out how preg_replace can do it. I have only ever been able to add something not read then add behind.
I have a site with 300,000+ pages and we are trying to make an anchor text link side bar. But first I need to add an ID to all my h2 tags so I have for example <h2>this is the title</h2>
and I need PHP to automatically on page render output <h2 id="this-is-the-title">This is the title</h2>
Unfortunatelly all attempts have failed. I have tried google but it's a hard one to search for as I am not exactly sure what it's called.
Any ideas on what this is called or code snippets?
", "
– Rizier123 Mar 14 '16 at 01:57", $dataFromDB);`
", "
– ThrowBackDewd Mar 14 '16 at 02:11, $oldh2string)`. It's hard to know if this will work for you though as I'm not sure how you're creating the original h2 string, in other words, how much of it is hard coded vs what's dynamic.