How do I get all images path from a string? Note I just want the path containing the word "media".
For example given this string (part of the DOM)
<div class="my-class">
<img src="http://my-website.com/cache/media/2017/10/img67.jpeg" class="" alt="test" width="120" height="100">
<img src="http://my-website.com/cache/2017/10/img68.png" class="" alt="test" width="120" height="100">
<img src="http://my-website.com/cache/media/2017/10/img69.jpg" class="" alt="test" width="120" height="100">
<h2 class="uk-margin-top-remove">About us</h2>
</div>
I want an array containing a similar result:
array(
[0] => "http://my-website.com/cache/media/2017/10/img67.png"
[1] => "http://my-website.com/cache/media/2017/10/img69.png"
);
I don't want the second img because src attribute doesn't contain the word "media".
php get src from imggives you lots of answers. Then you can easily tailor it to your issue. FYIregexis not ideal here.DOMDocument()is right