I have tried the above code... but it not working. i just want to change the whole <img>
tag with new src
and class
.. but i down know what attribute added into the <img>
tag... my validation are only if img
src
is matched then replace the whole <img>
tag with new one...
$match="abc.jpg";
$url ="<img class='descimg' src='111'>";
preg_replace('/<img[^>]*?src=\"'.preg_quote($match).'"',$url,$html);
pls help me
thank you
Further to me comment the following preg_replace line should work better. I can't actually tell from your description exactly what you are trying to do. If you included your expected output I will improve my answer as required to fit.
preg_replace('/<img[ ]+src=\"'.preg_quote($match).'"',$url,$html);
I also note that $match does not appear in the your original string and so it is odd that it is part of the regular expression?