$html = '<img src="/images/abc.jpg" title="image title" alt="image alt">';
$dom = new DOMDocument();
libxml_use_internal_errors(true); // Suppress warnings for malformed HTML
$dom->loadHTML($html);
libxml_clear_errors();
$images = $dom->getElementsByTagName('img');
foreach ($images as $img) {
$src = $img->getAttribute('src');
$imageName = basename($src);
$title = $img->getAttribute('title');
$alt = $img->getAttribute('alt');
echo "Src: $src, \nImageName: $imageName, \nTitle: $title, \nAlt: $alt\n";
}
/*
run:
Src: /images/abc.jpg,
ImageName: abc.jpg,
Title: image title,
Alt: image alt
*/