RegEx: remove <img which src attribute is empty
I want the regex pattern to delete images that have the src attribute empty, for example:
$html = '<img src="adasas.jpg" /><br />asasas<br />sdfsdf<br /><img title="asa" src="" />'; or
$html = '<img src="adasas.jpg" /><br />asasas<br />sdfsdf<br /><a href="adafgag"><img title="asa" src="" /></a>'; if this <img exists between the <a> , I also want to delete everything ( <a and <img ).
I checked the code below, but it deleted all $ html
echo preg_replace( '!(<a([^>]+)>)?<img(.*?)src=""([^>]+)>(</a>)?!si' , '' , $html ); Can anybody help me?
early
+4