Joe
Joe

Reputation: 3089

PHP regex to remove image from RSS

I'm using php to process rss data, however often feeds have more than image in the description. Can someone help me out with some regex or something to remove all but the first image in the feed? I'd only like to have a max of one image.

Assuming the feed description in is in a variable such as "Sdescription".

CLARIFICATIONS: I've used an xml parser, the string for the description tag just has multiple images, all I need to know is how to remove all images from a string except the first one.

Upvotes: 0

Views: 810

Answers (1)

Jason McCreary
Jason McCreary

Reputation: 72991

I don't think a regex is necessarily what you want. I'd parse the feed with one of PHP's XML readers and just pull out what you want - the first image.

Check out SimpleXML it should get you started.

Upvotes: 1

Related Questions