I am using regex in my PHP script to check a page for Rapidshare links, and load them into an array.
My code:
if(preg_match_all('/http:\/\/rapidshare\.com\/files\/.*?\/[^\s]+/', $links[0], $links))
{
print_r($links);
} else {
die('Cannot find post links :(');
}
It finds the links correctly, and puts them into an array:
Array
(
[0] => Array
(
[0] => http://rapidshare.com/files/320708377/file_name1.rar
[1] => http://rapidshare.com/files/320708377/file_name1.rar
[2] => http://rapidshare.com/files/333708133/file_name2.rar
[3] => http://rapidshare.com/files/333708133/file_name2.rar
[4] => http://rapidshare.com/files/330738827/file_name3.rar
[5] => http://rapidshare.com/files/330738827/file_name3.rar
)
)
As you can see, it enters two links into the array for each one. I have no clue why it's doing this but I suspect it's something to do with the regex.
Any help? Cheers. :)