Use a HTML parser like DomDocument parsing to get image src attribute value.
<php
$html = '<div id="chart_div"><img src="images.png"</div>';
$doc = new DOMDocument();
@$doc->loadHTML($html);
$tags = $doc->getElementsByTagName('img');
$imagename = "images/google_chart.png";
foreach ($tags as $tag) {
$img_src = $tag->getAttribute('src');
file_put_contents($imagename, file_get_contents($img_src));
}
echo $result ='<img src="'.$imagename.'">';
}
?>
No comments:
Post a Comment