View Full Version : find a html tag in string

11-26-2007, 05:40 AM

$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.

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


EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum