Hi
Is it possible to replace a particular string with a counter .Let me explain this
I have an array which conatain an html page . What i have to do is replace all the <img scr="http://mydomain.com/img1.gif"> tags with a counter.That is
If there are three "<img >" tags in an html page like <img scr="http://mydomain.com/img1.gif"> <img scr="http://mydomain.com/img2.gif"> <img scr="http://mydomain.com/img3.gif">
I have to replace "<img scr="http://mydomain.com/img1.gif">" with "1" . "<img scr="http://mydomain.com/img2.gif"> with "2" "<img scr="http://mydomain.com/img3.gif">" with "3"
Is it possible using regular expressions (preg_replace)
Rgds Thomas
Hi Thomas,
This should work:
$content = preg_replace('/(\<img src\=\"http\:\/\/mydomain.com\/img)(.*?)(\.gif\"\>)/','\\2',$content);
HTH
Mike