How can I find an HTML tag in a string with PHP?
This is a record in my database:
$str = "This is me <img src='images/mardagz.png' width='200' /> :) when i was 4th year highschool hahah so funny...";
I'm trying to get the contents of the <img>
tag. This is the code I am using:
$gimg = preg_match('/<img[^>]+\>/i', $str , $matches) ? $matches[1]: '<img src="http://facebook.com/username/profile.png" width="200" />
But, this code always gives me this error: Notice: Undefined offset: 1 in mardagz.blog\post.php on line 19
What should I do?