1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

How would you parse this?

Discussion in 'PHP' started by GeorgeB., Oct 27, 2006.

  1. #1
    OK I have a php script that goes out and grabs data from an amazon xml feed.

    Easy enough..

    But I only want the first image it returns. Right now it returns up to 10.

    Here's an example of the data it returns:
    How would you grab just the first image?
     
    GeorgeB., Oct 27, 2006 IP
  2. wmtips

    wmtips Well-Known Member

    Messages:
    601
    Likes Received:
    70
    Best Answers:
    1
    Trophy Points:
    150
    #2
    You can use xml functions or regex for doing that. Regex example:
    
    if (preg_match('/<image[^>]*><\/image>/si',$s,$m))
     echo $m[0];
    
    PHP:
    there $s contains your xml.
     
    wmtips, Oct 27, 2006 IP