The title is kinda unclear imo, but I couldnt find a better way to tell my concern. I am trying to get some pictures from Reddit. So when I tried to get the url to the image i got some problems.
$url = 'http://www.reddit.com/r/pics';
$str = file_get_contents($url);
This is what i currently have. To get the specific part in the url code where the image-url stands, I need to find this part of the html:
`<a class="thumbnail may-blank " href="http://i.imgur.com/K4q9i5c.jpg">`
As i was trying to figure out a way how to get each href of all the links on the page, I could only think about regex. Finding the part of
<a class="thumbnail may-blank "
and then find this > sign I could get the whole line. Where I eventually could get the url of the picture from.
So I have been trying and trying to find an regex to match is, I couldnt get it work. Maybe someone here can help me. Or either has a better solution.
It would be highly appreciated, Thanks