Activity Stream
48,167 MEMBERS
62296 ONLINE
besthostingforums On YouTube Subscribe to our Newsletter besthostingforums On Twitter besthostingforums On Facebook besthostingforums On facebook groups

Results 1 to 6 of 6
  1.     
    #1
    Member

    Smile 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

  2.   Sponsored Links

  3.     
    #2
    Retired NinJa
    Website's:
    loledhard.com
    PHP Code: 
    preg_match('/http:\/\/download.tamilwire.com(.*?).mp3/i',$source,$match); 
    ^ this should work



    You don't hate Justin bieber.You hate the fact you ain't Justin Bieber!

  4.     
    #3
    Member
    @ humour

    so the first link should be stored in $match[1] right ?

  5.     
    #4
    Retired NinJa
    Website'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); 
    now
    $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>
    when u use
    PHP Code: 
    preg_match_all('/http:\/\/download.tamilwire.com(.*?).mp3/i',$source,$match); 
    u will get
    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!

  6.     
    #5
    Member
    Website's:
    rapidgator.net

    Default thanks

    thanks sir

  7.     
    #6
    Member
    @ humour

    thank you very much.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. preg_match help need!
    By saninokia in forum Web Development Area
    Replies: 8
    Last Post: 27th Nov 2011, 08:39 PM
  2. A doubt about php's preg_match result.
    By PCManiac in forum Web Development Area
    Replies: 15
    Last Post: 28th May 2011, 09:03 AM

Tags for this Thread

BE SOCIAL