Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7904841
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T10:15:20+00:00 2026-06-03T10:15:20+00:00

i have no idea about php regex i wish to extract all image tags

  • 0

i have no idea about php regex i wish to extract all image tags <img src="www.google.com/exampleimag.jpg"> form my html how can i do this using preg_match_all

thanks SO community for u’r precious time

well my scenario is like this there is not whole html dom but just a variable with img tag $text="this is a new text <img="sfdsfdimg/pfdg.fgh" > there is another iamh <img src="sfdsfdfsd.png"> hjkdhfsdfsfsdfsd kjdshfsd dummy text

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T10:15:21+00:00Added an answer on June 3, 2026 at 10:15 am

    Don’t use regular expressions to parse HTML. Instead, use something like the DOMDocument that exists for this very reason:

    $html = 'Sample text. Image: <img src="foo.jpg" />. <img src="bar.png" />';
    $doc = new DOMDocument();
    $doc->loadHTML( $html );
    
    $images = $doc->getElementsByTagName("img");
    
    for ( $i = 0; $i < $images->length; $i++ ) {
      // Outputs: foo.jpg bar.png
      echo $images->item( $i )->attributes->getNamedItem( 'src' )->nodeValue;
    }
    

    You could also get the image HTML itself if you like:

    // <img src="foo.jpg" />
    echo $doc->saveHTML ( $images->item(0) );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have basic idea about running PHP in different configurations like mod_php, cgi, FastCGI,
i want to implement comet in php... i have idea about how ajax works
I have about 8 text inputs. They all get concatenated with PHP in the
I have no idea about PHP. I have PHP site hosted on Server A.
I have no idea about PHP security, but if I add an ' to
Anyone have idea about how to bind Boolean in sqlite with objective - c.
Anyone have any idea about CASlotProxy Class in Cocoa (iOS SDK)? I found it
Please let me know if you have any idea about it. Thanks EDIT What
I want to use a vertical UISlider . I have no idea about how,
I have a good idea about Agile development process but I have no ieda

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.