I want to get some URLs of images in Js/HTML: img class="img-responsive" id="Q72D2600000-MDYI" src="https://s7d5.scene7.com/is/image/Guess/Q72D2600000-MDYI?$2014_G_xxlarge$" alt="Q72D2600000-MDYI" />
Looking for solution that will detect image url. So the output will be: https://s7d5.scene7.com/is/image/Guess/Q72D2600000-MDYI?$2014_G_xxlarge$
0
votes
1 Answers
0
votes
The below code may be helpfull
$html = '<img class="img-responsive" id="Q72D2600000-MDYI" src="https://s7d5.scene7.com/is/image/Guess/Q72D2600000-MDYI?$2014_G_xxlarge$" alt="Q72D2600000-MDYI" />';
preg_match('/<img\s.*?\bsrc="(.*?)".*?>/si', $html, $matches);
$image_src = $matches[1];
echo $image_src;
Output
https://s7d5.scene7.com/is/image/Guess/Q72D2600000-MDYI?$2014_G_xxlarge$
srcattribute. - chris85