preg_match_all

Discussion in 'PHP' started by Kennedy, Mar 27, 2008.

  1. #1
    I have a string with html code and lots of images in it. What I want to do is grab the URL of all those images. Normally, I'd just use this:

    preg_match_all("/<img src=\"(.*?)\"/si",$data,$matches);

    but some of the images aren't structured that way. For example:
    <img src='img.jpg'>
    <img src=img.jpg alt="an image">

    How can I code it so it grabs the image url no matter what?
     
    Kennedy, Mar 27, 2008 IP
  2. stephan2307

    stephan2307 Well-Known Member

    Messages:
    1,277
    Likes Received:
    33
    Best Answers:
    7
    Trophy Points:
    150
    #2
    Maybe this will help you


    http://www.web-development-blog.com/archives/parse-html-with-preg_match_all/
     
    stephan2307, Mar 27, 2008 IP