1

I'm an average level PHP coder and I'm trying to grab all images and iframes from within my html content, but I've managed to exceed my ability level!

I have two different calls which both work independently:

function get_the_images($content) {

     //$matches will be an array with all images
     preg_match_all("/<img[^>]+\>/i", $content, $matches);
     return $matches;

}

function get_the_iframes($content) {

     //$matches will be an array with all iframes
     preg_match_all('#(?:<iframe[^>]*)(?:(?:/>)|(?:>.*?</iframe>))#i', $content, $matches);
     return $matches;

}

What I'd like to do is combine those 2 into one single preg_match_all search. Can anyone help me combine the two together?

Thanks in advance for any help!

Raffacake
  • 21
  • 1
  • 1
    *`DOMDocument` guys... [`DOMDocument`](http://php.net/manual/en/class.domdocument.php)!* – revo May 25 '17 at 08:28

0 Answers0