Forum Moderators: coopster
I'd like search a string for a link
for example
The following link is in the string
<a href=http://mysite.com/page.php><img src="http://mysite.com/img.gif" /></a>
i'd like to search the entire string for that specific url. then would like to get the location of the image that is inside the <a> tag
could anyone help?!
preg_match($p, $a, $matches);
print_r($matches);
?>
Output =
Array ( [0] => *actual link in here* => http://example.com/page.php [2] => http://example.com/img.gif ) However there is a note in the manual - [1][edited by: coopster at 4:33 pm (utc) on Oct. 8, 2007]
Do not use preg_match() if you only want to check if one string is contained in another string. Use strpos() or strstr() instead as they will be faster.
So I guess it depends on what you are doing with the results of the match if you will go for preg_match¦strpos¦strstr
[edit reason] examplified [/edit]