I have a string that contains an <img>
tag somewhere in text entered by users. I want to get rid of all the text but keep the image tag but I have no idea how to do that, is it possible?
$str = "<img src= 'imagepath'/> Lorem ipsum dolor sit amet, consectetur adipiscing elit"
What I want it to do is only keep the and get rid of all the other text and instead look like this:
$str = "<img src='imagepath'/>"