Jump to content

tobeyt23

Members
  • Posts

    259
  • Joined

  • Last visited

Everything posted by tobeyt23

  1. Think i got it: <?php $ad = "<div class="image-advertisement" id="ad-306"><a href="http://www.appraisalbuzz.com/ad/redirect/306/0" onclick="window.open(this.href); return false;"><img src="http://appraisalbuzz.com/sites/default/files/FREA_BannerWebinarBrianT.gif" alt="" title="" width="468" height="60" /></a></div><div class="links-to">Links to http://www.frea.com/</div>"; $pattern = array(); $pattern[0] = '/<div class="image-advertisement" id="ad-[0-9]+">/'; $pattern[1] = '/<\/div><div class="links-to">Links to (http|ftp|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&:\/~\+#]*[\w\-\@?^=%&\/~\+#])?+/'; $replace = array(); $replace[0] = ''; $replace[1] = ''; echo preg_replace($pattern, $replace, $ad); ?>
  2. I have made some progress just can't seem to get the url : <?php $ad = "<div class="image-advertisement" id="ad-306"><a href="http://www.appraisalbuzz.com/ad/redirect/306/0" onclick="window.open(this.href); return false;"><img src="http://appraisalbuzz.com/sites/default/files/FREA_BannerWebinarBrianT.gif" alt="" title="" width="468" height="60" /></a></div><div class="links-to">Links to https://www.frea.com/.</div>"; $pattern = array(); $pattern[0] = '/<div class="image-advertisement" id="ad-[0-9]+">/'; $pattern[1] = '/<\/div><div class="links-to">Links to ((?:http:\/\/)?[a-zA-Z0-9:\._-]+)[\'\"]>(.*?)<\/div> /'; $replace = array(); $replace[0] = ''; $replace[1] = ''; echo preg_replace($pattern, $replace, $ad); ?>
  3. I am getting a rss feed of ads and I need to remove some on the string so that i can use it properly. $ad = urldecode("<div class="image-advertisement" id="ad-306"><a href="http://www.appraisalbuzz.com/ad/redirect/306/0" onclick="window.open(this.href); return false;"><img src="http://appraisalbuzz.com/sites/default/files/FREA_BannerWebinarBrianT.gif" alt="" title="" width="468" height="60" /></a></div><div class="links-to">Links to https://www.frea.com/.</div>"); echo preg_replace('/<div class="image-advertisement" id="ad-{0-9}+">/', '', $ad); What I am trying to do is remove : <div class="image-advertisement" id="ad-306"> and then </div><div class="links-to">Links to https://www.frea.com/.</div>. The problem is the id="ad-XXX" will always be different as well as the </div><div class="links-to">Links to XXXXXXXXXXXXXXXXXXX</div> The end result should be : <a href="http://www.appraisalbuzz.com/ad/redirect/306/0" onclick="window.open(this.href); return false;"><img src="http://appraisalbuzz.com/sites/default/files/FREA_BannerWebinarBrianT.gif" alt="" title="" width="468" height="60" /></a> Any help would be greatly appreciated.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.