...

View Full Version : find a html tag in string



shaileshpatil
11-26-2007, 06:40 AM
Hi



$string=' this is image 1 <img src="www.abc.com/abc.gif"'> and second is <img src="www.df.com/edfg.jpg">;
function getAttribs($t, $a, $s) {
preg_match_all("/(<".$t." .*?".$a.".*?=.*?\")(.*?)(\".*?>)/", $s, $m);
return $m[2];
}
$arr=getAttribs('img', 'src', $string);


Here i get all the src of <img> tag.
Now i want to replace the src part with something else.
How can i achieve this.


thanks in advance.

shaileshpatil
11-26-2007, 12:11 PM
The output of the above function was array.
I looped through foreach and used str_replace() function.

Thanks



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum