yes - that's good - thanks 🙂
when I tested it the result was it captured the whole <img> tag like this :
<img src="http://www.mysite.com/images/myImage.jpg" class="img-left" style="width:200px;" />
but I just needed the src, so I did a bit of research and came across named subpatterns, which I'd never heard of, like this :
if (preg_match("/<img [^>]*src=[\"'](?P<url>.+?)[\"'][^>]*>/i", $str, $matches)) {
echo "A match was found: ".$matches['url'];
} else {
echo "A match was not found.";
}
which outputs :
http://www.mysite.com/images/myImage.jpg
now this is very nice, but what I'd really like would be to get just the filename (and not the whole path with the http etc) so that I can use file_exists() with the server path to the images directory
is there a simple-ish way to change the regex so that it will do this ?
or should I just use explode("/",$matches['url']) to get the filename ?