Results 1 to 6 of 6
-
21st May 2011, 03:46 PM #1OPMember
Help with preg_match - php !
Hi everyone !
Take a look at the source of this webpage :
http://mp3.tamilwire.com/mankatha-2011.html
So this source page has many links with it.(<a></a>)
But this page has links to 5 mp3 songs. They are :
<a target="_blank" href="http://download.tamilwire.com/songs/__K_O_By_Movies/Mankatha/Vilayadu%20Mankatha%20-%20TamilWire.com.mp3">Vilayadu Mankatha ? TamilWire.com.mp3</a> (11.1 MB)</li> <a target="_blank" href="http://download.tamilwire.com/songs/__K_O_By_Movies/Mankatha/Dia%20Dia%20Dole%20-%20TamilWire.com.mp3">Dia Dia Dole ? TamilWire.com.mp3</a> (7.4 MB)</li> <a target="_blank" href="http://download.tamilwire.com/songs/__K_O_By_Movies/Mankatha/Goa%20-%20TamilWire.com.mp3">Goa ? TamilWire.com.mp3</a> (8.4 MB)</li> <a target="_blank" href="http://download.tamilwire.com/songs/__K_O_By_Movies/Mankatha/Theeratha%20Vilaiyattu%20-%20TamilWire.com.mp3">Theeratha Vilaiyattu ? TamilWire.com.mp3</a> (8.9 MB)</li> <a target="_blank" href="http://download.tamilwire.com/songs/__K_O_By_Movies/Mankatha/Yogi%20Yogi%20Thaan%20-%20TamilWire.com.mp3">Yogi Yogi Thaan ? TamilWire.com.mp3</a> (7.0 MB)</li>
If you take a close look at these links, these links are distinct from other links in the page.
1. These are the only 5 links which have an extension ".mp3"
2. These are the only 5 links which start with "http://download" at the beginning.
So i want now is to grab these 5 links alone from this page using php code.
This can be possibly done by the " preg_match " statement.
A statement like this will select the entire links from page :
$res=file_get_contents($url);
preg_match('/<a([^>]+)\>(.*?)\<\/a\>/i',$res,$match);
What i want you to do is that , you should change the preg_match statement (i mean the regular expression in it) so that it select only the above five mp3 links from the page.
Thanks.softleaks Reviewed by softleaks on . Help with preg_match - php ! Hi everyone ! Take a look at the source of this webpage : http://mp3.tamilwire.com/mankatha-2011.html So this source page has many links with it.(<a></a>) But this page has links to 5 mp3 songs. They are : Rating: 5
-
21st May 2011, 03:57 PM #2Retired NinJaWebsite's:
loledhard.comPHP Code:preg_match('/http:\/\/download.tamilwire.com(.*?).mp3/i',$source,$match);
You don't hate Justin bieber.You hate the fact you ain't Justin Bieber!
-
21st May 2011, 04:03 PM #3OPMember
@ humour
so the first link should be stored in $match[1] right ?
-
21st May 2011, 04:05 PM #4Retired NinJaWebsite's:
loledhard.com^ no
$match[0]
if u want to match all mp3 links than
PHP Code:preg_match_all('/http:\/\/download.tamilwire.com(.*?).mp3/i',$source,$match);
$match[0][0]
$match[0][1]
$match[0][2]
& so on will store ur links
example:
for
Code:<a target="_blank" href="http://download.tamilwire.com/songs/__K_O_By_Movies/Mankatha/Vilayadu%20Mankatha%20-%20TamilWire.com.mp3">Vilayadu Mankatha – TamilWire.com.mp3</a> (11.1 MB)</li> <a target="_blank" href="http://download.tamilwire.com/songs/__K_O_By_Movies/Mankatha/Dia%20Dia%20Dole%20-%20TamilWire.com.mp3">Dia Dia Dole – TamilWire.com.mp3</a> (7.4 MB)</li> <a target="_blank" href="http://download.tamilwire.com/songs/__K_O_By_Movies/Mankatha/Goa%20-%20TamilWire.com.mp3">Goa – TamilWire.com.mp3</a> (8.4 MB)</li> <a target="_blank" href="http://download.tamilwire.com/songs/__K_O_By_Movies/Mankatha/Theeratha%20Vilaiyattu%20-%20TamilWire.com.mp3">Theeratha Vilaiyattu – TamilWire.com.mp3</a> (8.9 MB)</li> <a target="_blank" href="http://download.tamilwire.com/songs/__K_O_By_Movies/Mankatha/Yogi%20Yogi%20Thaan%20-%20TamilWire.com.mp3">Yogi Yogi Thaan – TamilWire.com.mp3</a> (7.0 MB)</li>
PHP Code:preg_match_all('/http:\/\/download.tamilwire.com(.*?).mp3/i',$source,$match);
Code:Array ( [0] => Array ( [0] => http://download.tamilwire.com/songs/__K_O_By_Movies/Mankatha/Vilayadu%20Mankatha%20-%20TamilWire.com.mp3 [1] => http://download.tamilwire.com/songs/__K_O_By_Movies/Mankatha/Dia%20Dia%20Dole%20-%20TamilWire.com.mp3 [2] => http://download.tamilwire.com/songs/__K_O_By_Movies/Mankatha/Goa%20-%20TamilWire.com.mp3 [3] => http://download.tamilwire.com/songs/__K_O_By_Movies/Mankatha/Theeratha%20Vilaiyattu%20-%20TamilWire.com.mp3 [4] => http://download.tamilwire.com/songs/__K_O_By_Movies/Mankatha/Yogi%20Yogi%20Thaan%20-%20TamilWire.com.mp3 ) [1] => Array ( [0] => /songs/__K_O_By_Movies/Mankatha/Vilayadu%20Mankatha%20-%20TamilWire.com [1] => /songs/__K_O_By_Movies/Mankatha/Dia%20Dia%20Dole%20-%20TamilWire.com [2] => /songs/__K_O_By_Movies/Mankatha/Goa%20-%20TamilWire.com [3] => /songs/__K_O_By_Movies/Mankatha/Theeratha%20Vilaiyattu%20-%20TamilWire.com [4] => /songs/__K_O_By_Movies/Mankatha/Yogi%20Yogi%20Thaan%20-%20TamilWire.com ) )
You don't hate Justin bieber.You hate the fact you ain't Justin Bieber!
-
21st May 2011, 04:05 PM #5MemberWebsite's:
rapidgator.netthanks
thanks sir
-
21st May 2011, 04:22 PM #6OPMember
@ humour
thank you very much.
Sponsored Links
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Similar Threads
-
preg_match help need!
By saninokia in forum Web Development AreaReplies: 8Last Post: 27th Nov 2011, 08:39 PM -
A doubt about php's preg_match result.
By PCManiac in forum Web Development AreaReplies: 15Last Post: 28th May 2011, 09:03 AM
themaManager - edit and manage...
Version 4.04 released. Open older version (or...