Hey guys,
I've created a system for my website whereby images I upload are automatically thumbnailed, watermarked and saved in the database, ready to be loaded against relevant articles and this all works fine and dandy.
(You can see an example page <a href="http://www.allaboutthegames.co.uk/feature_story.php?headline=Banjo-Kazooie--Nuts---Bolts-Review&article_id=8689">here</a>.
However, following on from completing this task, I now want to be able to have my pages automatically insert thumbnails into the body of my text - at the start of each new paragraph and left aligned so the text flows around it. I figured I could just do a preg_replace on the $body variable (which contains all each article's text) and replace <br /><br /> with <br /><br/>$thumbnail_link and limit this to 3 per article. But then I realised I'd need to run my preg_replace in a for loop to change the $thumbnail link for each different image. But then in realising that, I also then realised that each time the loop runs, the replace will replace the very first instance of <br /><br /> because even though it will have the thumbnail link directly after it, it will still be <br /><br />.
So does anyone know if there's anyway of parsing through a block of text and replacing the first, then second, then third set of <br /><br />s in order to do what I want to do?