У меня проблема с функцией PHP preg_match
.
В CMS DLE я пытаюсь извлечь картинку из новостей (image-x), но в модуле, к которому я обращаюсь черезпрямая ссылка.
//remove <p></p> tags
$row[$i]['short_story'] = str_replace( "</p><p>", " ",$row[$i]['short_story'] );
//remove the \" escapes (DLE put it in the MySQL column)
$row[$i]['short_story'] = str_replace("\\\"", " ", $row[$i]['short_story']);
//remove all tags except <img>, but there remains a simple text that is stored without tags
$row[$i]['img'] = strip_tags($row[$i]['short_story'], "<img>");
//try to find <img> (by '>'), to remove the simple text;
preg_match(".*>", $row[$i]['img'], $matches);
// print only <br/> (matches is empty)
print_r($matches."<br/>\n");
например print_r($row[$i]['img'])
это
<img src="somelink" class="fr-fic" fr-dib="" alt=""> Some text
И мне нужно только
<img src="somelink" class="fr-fic" fr-dib="" alt="">