I have html string in variable in php. I want to get tag from it. For example :
$str ='<p><img src="link"></p><p>text</p>';
How can I get <img src="link">
(or any img
tag plus its content) from this string?
User Regex in php. You should write regular expression for it
http://php.net/manual/en/function.preg-match.php
<img\s[^<>]*>