Hi all, I'm quite new to this forum and PHP in general, so please bear with me.
My curent objective is to take a website URL, convert the contents of that website into a string using "file_get_contents()", then analyze that string for any JPG or GIF URLs and output the URLs to the screen. I've been doing some research and the closest thing I can find to what I want is the "preg_match()" function (http://php.net/manual/en/function.preg-match.php ). There are two problems that I have with preg_match(); 1. is that it only searches for a predefined set of characters, not any URL starting with http:// and ending with .jpg/.gif. 2. is that it only returns a true or false statement, not the URL.
Here's my code so far:
$url = file_get_contents("http://-ENTER_URL-");
$pattern = "/jpg/" //tells me if there is a jpg in the file.
echo preg_match($pattern, $url); //outputs 0 or 1.
What I want the above code to do is take the URL, look at the source and return any JPG or GIF URLs.
Any help is greatly appreciated!