Need to remove link and image information from rss feed and save rest as variable

Discussion in 'PHP' started by ziplock122949, Feb 21, 2011.

  1. #1
    Well, I though I was almost done with an rss feed aggregator, but I have run into a new problem: links and images. I am using a tooltip script that on mouse over is showing part of the description from an rss post. The only issue I was having was changing apostrophes into \' but that got fixed. I just tried adding a feed that has links and images and it really screwed things up. Anyone know how to extract just the text from the post and not the image or link code?

    Below is the description from a post of the rss feed

    <description>
            <![CDATA[
    	  <p align="center"><a href="http://www.amazon.com/gp/redirect.html?ie=UTF8&location=http%3A//www.amazon.com/Nikon-camera-35mm-body-only/product-reviews/B0006GQ6K6?ie=UTF8&showViewpoints=0&filterBy=addOneStar&tag=kenrockwellcom&linkCode=ur2&camp=1789&creative=9325" target="_blank"><img src="http://www.kenrockwell.com/nikon/f6/images/D3S_2106-460.jpg" alt="Nikon F6" width="460" height="391" border="0"></a></p>
    	  <p align="center"><b>The Nikon F6. </b></p>
    	  <p><b><font size="+1">The Nikon F6</font></b></p>
    	  <p><a href="http://www.amazon.com/gp/redirect.html?ie=UTF8&location=http%3A//www.amazon.com/Nikon-camera-35mm-body-only/product-reviews/B0006GQ6K6?ie=UTF8&showViewpoints=0&filterBy=addOneStar&tag=kenrockwellcom&linkCode=ur2&camp=1789&creative=9325" target="_blank">Some people just don't get</a> the  <a href="http://www.kenrockwell.com/nikon/f6.htm">Nikon F6</a>, the world's best 35mm SLR. </p>
    	  <p>&nbsp;</p>
            ]]>
          </description>
    
    Code (markup):
    All I want the output to be is the following

    Some people just don't get the Nikon F6, the world's best 35mm SLR. (click the 1-star ratings if my link doesn't bring you right to the customer comment on Amazon.
    Code (markup):
     
    ziplock122949, Feb 21, 2011 IP
  2. MyVodaFone

    MyVodaFone Well-Known Member

    Messages:
    1,048
    Likes Received:
    42
    Best Answers:
    10
    Trophy Points:
    195
    #2
    Something like this, assuming $content is your current echoed variable output:
    
    echo strip_tags($content, '<p><b>'); // which allows tags <p and b> through, removing all others.
    
    PHP:
     
    MyVodaFone, Feb 21, 2011 IP
  3. ziplock122949

    ziplock122949 Active Member

    Messages:
    159
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    60
    #3
    Worked like a charm, thanks so much.
     
    ziplock122949, Feb 22, 2011 IP