I have a table with rows of small bits of html code.

I have already set it up to look for each row that has an image in the code like so

<img src="http://www.site.com/file.jpg" width="80" height="90">

I need to create a program with preg_match and preg_replace that will first find the image file's source and then remove the entire image tag.

the image tags can be slightly different. some have the '/' at the end and some come with alt tags.

How can I do this? I need to get the source then remove the whole thing entirely.

Thanks
Ryan

    if I undertand correctly, you need the img src's before removing them? Try this (untested) code:

    preg_match_all('/http:\/\/[^"]+(gif|jpg|jpeg|png)/Ui', $page, $img_srcs);
    $page = preg_replace('/<\s*img[^>]+>/Ui', '', $page);
    
      Write a Reply...