Click here to Skip to main content
15,895,538 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
i need to find all src images in the following link


XML
$url='http://www.firstcovers.com/tags/2/covers.html?infinity';

$pattern = '#src="([^"]+/temp/temp[a-z0-9]{13}\.jpeg)"#';
preg_match_all($pattern, $url, $out);
echo '<pre>';
print_r($out);



the output give me a null array the question is is there any way to get src of all images in the given link using php ?
Posted
Comments
Sergey Alexandrovich Kryukov 2-Feb-14 14:10pm    
Why? If this URL yours, or 3rd-party? What's the problem?
—SA
TheSniper105 2-Feb-14 15:04pm    
$out
is empty array why ??
Sergey Alexandrovich Kryukov 2-Feb-14 15:29pm    
Well, because no match is found. Download HTML source, just one ore more samples, and try Regex, say, of the text editor, like the one of Visual Studio. You will be able to find your mistakes in no time and develop correct Regex.

But how can you expect a match? Where is the document you are trying to find the match in, correct or not?.. :-)
—SA
TheSniper105 2-Feb-14 16:30pm    
yeas thank you you are right
Sergey Alexandrovich Kryukov 2-Feb-14 17:36pm    
You are welcome. Good luck, call again.
—SA

1 solution

Please see my advice in my comment to the question. However, I don't see where do you have the HTML document downloaded using your URL. It looks like you are trying to do Regex match with the text of URL itself, not the HTML document.

Do download an HTML page by URL using HTTP request, you can use PHP HttpRequest:
http://www.php.net/manual/en/class.httprequest.php[^].

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900