find URL in code

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
fer0an
Forum Newbie
Posts: 12
Joined: Sat Jan 23, 2010 8:15 am

find URL in code

Post by fer0an »

hello
I've some code same as below:

Code: Select all

<div class="center"><a href="http://hotfile.com/dl/58656550/d2428c9/INV.1908.pdf.html" target="_blank" rel="nofollow">Hotfile</a><br/>
<br/>
<a href="http://sharingmatrix.com/file/15447295/INV.1908.pdf" target="_blank" rel="nofollow">Sharingmatrix</a></div>
</div>
now I wan extract URL of links from it.
sometimes this codes have 1 or 2 or 3 url.
can anyone help me?
fer0an
Forum Newbie
Posts: 12
Joined: Sat Jan 23, 2010 8:15 am

Re: find URL in code

Post by fer0an »

preg_match_all('#<a[^>]* href=("|\')([^\1]+)\1[^>]*>#U', $input, $out);
print_r($out);
Post Reply