<?php
$string = '<!-- Begin: AdBrite, Generated: 2008-12-18 16:23:11 -->
<script type="text/javascript">
var AdBrite_Title_Color = \'015990\';
var AdBrite_Text_Color = \'2D3F52\';
var AdBrite_Background_Color = \'FFFFFF\';
var AdBrite_Border_Color = \'CCCCCC\';
var AdBrite_URL_Color = \'CC0000\';
try{var AdBrite_Iframe=window.top!=window.self?2:1;var AdBrite_Referrer=document.referrer==\'\'?document.location:document.referrer;AdBrite_Referrer=encodeURIComponent(AdBrite_Referrer);}catch(e){var AdBrite_Iframe=\'\';var AdBrite_Referrer=\'\';}
</script>
<span style="white-space:nowrap;"><script type="text/javascript">document.write(String.fromCharCode(60,83,67,82,73,80,84));document.write(\' src="http://ads.adbrite.com/mb/text_group.php?sid=966656&zs=3732385f3930&ifr=\'+AdBrite_Iframe+\'&ref=\'+AdBrite_Referrer+\'" type="text/javascript">\');document.write(String.fromCharCode(60,47,83,67,82,73,80,84,62));</script>
<a target="_top" href="http://www.adbrite.com/mb/commerce/purchase_form.php?opid=966656&afsid=1"><img src="http://files.adbrite.com/mb/images/adbrite-your-ad-here-leaderboard.gif" style="background-color:#CCCCCC;border:none;padding:0;margin:0;" alt="Your Ad Here" width="14" height="90" border="0" /></a></span>
<!-- End: AdBrite -->';
$pattern = '/<!-- Begin: AdBrite, Generated: .*? -->((.|[\r\n])*?)<!-- End: AdBrite -->/';
$replacement = '<!-- Begin: AdBrite, Generated: '.date('Y-m-d H:i:s').' -->
NEW AD
<!-- End: AdBrite -->';
echo preg_replace( $pattern, $replacement, $string );
This is pretty rough, and i think the pattern could probably be fixed up but it seems to match and work properly.
I assume you're using PHP5 not that there should be any difference, but if you run that you should see:
<!-- Begin: AdBrite, Generated: 2008-12-27 00:41:43 -->
NEW AD
<!-- End: AdBrite -->
Hope that helps you.
Reputation Points: 265
Solved Threads: 126
Practically a Master Poster
Offline 624 posts
since Jul 2008