How to remove first link with image from this text with PHP?
<a href="some link"><img src="image link" /></a>Lorem ipsum dolor sit amet, consectetur adipiscing elit.**
I would start by splitting the line by the '>' character..
PHP:
$line = "<a href=''><img src=''></a>blah blah blah";
$parts = explode('>', $line);
If you wanted the image....
$img = $parts[1].">";
If you want just the text...
$text = $parts[3];
$str = '<a href="some link"><img src="image link"></a>Lorem ipsum dolor sit amet, consectetur adipiscing elit.<a href="some link"><img src="image link"></a>';
// strip the entire <a> tag including contents (first occurrence only)
$str = preg_replace('/<a.*?<\/a>/', '', $str, 1);
// strip only the <a> leaving the inner HTML (first occurrence only)
$str = preg_replace('/<a[^>]*>(.*?)<\/a>/', '$1', $str, 1);
$doc = DOMDocument::loadHTML($html);
$link = $doc->getElementsByTagName('a')->item(0);
$link->parentNode->removeChild($link);
$html = $doc->saveHTML();