Hi, You know how some websites have a page of text and somehow in various places they put related adverts in it? A bit like this tiny example: [!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]This is a 1st paragraphe of text SOME FANCY AND ANNOYING ADVERT THAT DISTRACTS YOU FROM ARTICLE This is another paragraphe[/quote] How do they do it? Is there a better way of doing it than using "ereg_replace" like this? (wouldn't it be great if one could put PHP scripts into a DB) [code]//I get my normal text from db $textfromdb="<p>This is a 1st paragraphe of text</p><p>This is another paragraphe</p>"; // search for paragraphe break $searchtext="</p><p>"; //could be a specially inserted tag //get my advert from db $some_advert = "<img src="image.gif">"; //This would also come from a db //do search and replace $bodytext = ereg_replace ($textfromdb, $searchtext, $some_advert); //output result echo $bodytext;[/code] Any suggestions? By the way, I'm not using it for putting annoying adverts into text, I hate that but its a good example that we're all subject to, so easy to visualise. I have a need to put dynamic stuff in the contents that comes out of a DB (from 1 table cell) such as display 1 client testimonial randomly selected from a list or a randomly selected illustration picked from a selection, examples go on... Any suggestions how to do this a better way? Maybe some techique or function that I've never heard of... ... much appreciated!