i want a regex pattern to remove images which src attribute is 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
exist between <a>
tag, i want also remove all ( <a
and <img
) .
I Tested below code, but it removed all of $html
echo preg_replace( '!(<a([^>]+)>)?<img(.*?)src=""([^>]+)>(</a>)?!si' , '' , $html );
Can anybody help to me ?
thanks in advance