Buying PHP Array to grab string

Discussion in 'Programming' started by bunbunx2, Apr 19, 2010.

  1. #1
    PHP Array to grab string

    I need a code to be done..

    lets say i have a variable call $content, and its value is equal to the below.


    
    
    <embed src="http://i312.photobucket.com/albums/ll351/baokychen/player.swf" width="480" height="400" bgcolor="#ffffff" allowscriptaccess="always" allowfullscreen="true" flashvars="config=http://www.animeshippuuden.com/xml.php?url=http://dc230.4shared.com/img/261579810/12e6e875/dlink__2Fdownload_2F261579810_2F12e6e875_3Ftsid_3D20100411-133409-3d47317f/preview.flv"/>
    
    Part 2
    <embed src="http://i312.photobucket.com/albums/ll351/baokychen/player.swf" width="480" height="400" bgcolor="#ffffff" allowscriptaccess="always" allowfullscreen="true" flashvars="config=http://www.animeshippuuden.com/xml.php?url=http://dc230.4shared.com/img/261580266/460b860a/dlink__2Fdownload_2F261580266_2F460b860a_3Ftsid_3D20100411-133434-e86cfc61/preview.flv"/>
    
    
    Code (markup):
    If you notice there is 2 link, i want to use array to grab the first link, then grab the second link.

    Start from url= till the "/>

    Then lets say now

    array[1] = http://dc230.4shared.com/img/261579...3Ftsid_3D20100411-133409-3d47317f/preview.flv

    and

    array[2] = http://dc230.4shared.com/img/261580...3Ftsid_3D20100411-133434-e86cfc61/preview.flv

    I want reproduce it out in echo as

    Array 1 - http://dc230.4shared.com/img/261579...3Ftsid_3D20100411-133409-3d47317f/preview.flv

    Array 2 - http://dc230.4shared.com/img/261580...3Ftsid_3D20100411-133434-e86cfc61/preview.flv


    The first guy with the coding solution to my p.m with working will get $10 usd, do send your paypal detail also for easy payment.
     
    bunbunx2, Apr 19, 2010 IP
  2. bunbunx2

    bunbunx2 Peon

    Messages:
    613
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #2
    job done by ansi.
     
    bunbunx2, Apr 19, 2010 IP
  3. ansi

    ansi Well-Known Member

    Messages:
    1,483
    Likes Received:
    65
    Best Answers:
    0
    Trophy Points:
    100
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #3
    send you a pm, to use it do this

    
    <?php
        $content ='<embed src="http://i312.photobucket.com/albums/ll351/baokychen/player.swf" width="480" height="400" bgcolor="#ffffff" allowscriptaccess="always" allowfullscreen="true" flashvars="config=http://www.animeshippuuden.com/xml.php?url=http://dc230.4shared.com/img/261579810/12e6e875/dlink__2Fdownload_2F261579810_2F12e6e875_3Ftsid_3D20100411-133409-3d47317f/preview.flv"/>
    
    Part 2
    <embed src="http://i312.photobucket.com/albums/ll351/baokychen/player.swf" width="480" height="400" bgcolor="#ffffff" allowscriptaccess="always" allowfullscreen="true" flashvars="config=http://www.animeshippuuden.com/xml.php?url=http://dc230.4shared.com/img/261580266/460b860a/dlink__2Fdownload_2F261580266_2F460b860a_3Ftsid_3D20100411-133434-e86cfc61/preview.flv"/>';
    
        preg_match_all('/url=(.*?flv)/sim', $content, $result, PREG_PATTERN_ORDER);
        $result = $result[0];
    
        foreach( $result as $key => $url )
            printf('<p>Array %d - %s</p>', (int)$key, $url );
    
    ?>
    
    PHP:
     
    ansi, Apr 19, 2010 IP
  4. ansi

    ansi Well-Known Member

    Messages:
    1,483
    Likes Received:
    65
    Best Answers:
    0
    Trophy Points:
    100
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #4
    awesome, thank you sir.
     
    ansi, Apr 19, 2010 IP
  5. ansi

    ansi Well-Known Member

    Messages:
    1,483
    Likes Received:
    65
    Best Answers:
    0
    Trophy Points:
    100
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #5
    everything working as it should? here's the revised code that's actually tested

    
    <?php
        $content ='<embed src="http://i312.photobucket.com/albums/ll351/baokychen/player.swf" width="480" height="400" bgcolor="#ffffff" allowscriptaccess="always" allowfullscreen="true" flashvars="config=http://www.animeshippuuden.com/xml.php?url=http://dc230.4shared.com/img/261579810/12e6e875/dlink__2Fdownload_2F261579810_2F12e6e875_3Ftsid_3D20100411-133409-3d47317f/preview.flv"/> Part 2 <embed src="http://i312.photobucket.com/albums/ll351/baokychen/player.swf" width="480" height="400" bgcolor="#ffffff" allowscriptaccess="always" allowfullscreen="true" flashvars="config=http://www.animeshippuuden.com/xml.php?url=http://dc230.4shared.com/img/261580266/460b860a/dlink__2Fdownload_2F261580266_2F460b860a_3Ftsid_3D20100411-133434-e86cfc61/preview.flv"/><embed src="http://i312.photobucket.com/albums/ll351/baokychen/player.swf" width="480" height="400" bgcolor="#ffffff" allowscriptaccess="always" allowfullscreen="true" flashvars="config=http://www.animeshippuuden.com/xml.php?url=http://dc230.4shared.com/img/261579810/12e6e875/dlink__2Fdownload_2F261579810_2F12e6e875_3Ftsid_3D20100411-133409-3d47317f/preview.flv"/> Part 2 <embed src="http://i312.photobucket.com/albums/ll351/baokychen/player.swf" width="480" height="400" bgcolor="#ffffff" allowscriptaccess="always" allowfullscreen="true" flashvars="config=http://www.animeshippuuden.com/xml.php?url=http://dc230.4shared.com/img/261580266/460b860a/dlink__2Fdownload_2F261580266_2F460b860a_3Ftsid_3D20100411-133434-e86cfc61/preview.flv"/><embed src="http://i312.photobucket.com/albums/ll351/baokychen/player.swf" width="480" height="400" bgcolor="#ffffff" allowscriptaccess="always" allowfullscreen="true" flashvars="config=http://www.animeshippuuden.com/xml.php?url=http://dc230.4shared.com/img/261579810/12e6e875/dlink__2Fdownload_2F261579810_2F12e6e875_3Ftsid_3D20100411-133409-3d47317f/preview.flv"/> Part 2 <embed src="http://i312.photobucket.com/albums/ll351/baokychen/player.swf" width="480" height="400" bgcolor="#ffffff" allowscriptaccess="always" allowfullscreen="true" flashvars="config=http://www.animeshippuuden.com/xml.php?url=http://dc230.4shared.com/img/261580266/460b860a/dlink__2Fdownload_2F261580266_2F460b860a_3Ftsid_3D20100411-133434-e86cfc61/preview.flv"/><embed src="http://i312.photobucket.com/albums/ll351/baokychen/player.swf" width="480" height="400" bgcolor="#ffffff" allowscriptaccess="always" allowfullscreen="true" flashvars="config=http://www.animeshippuuden.com/xml.php?url=http://dc230.4shared.com/img/261579810/12e6e875/dlink__2Fdownload_2F261579810_2F12e6e875_3Ftsid_3D20100411-133409-3d47317f/preview.flv"/> Part 2 <embed src="http://i312.photobucket.com/albums/ll351/baokychen/player.swf" width="480" height="400" bgcolor="#ffffff" allowscriptaccess="always" allowfullscreen="true" flashvars="config=http://www.animeshippuuden.com/xml.php?url=http://dc230.4shared.com/img/261580266/460b860a/dlink__2Fdownload_2F261580266_2F460b860a_3Ftsid_3D20100411-133434-e86cfc61/preview.flv"/><embed src="http://i312.photobucket.com/albums/ll351/baokychen/player.swf" width="480" height="400" bgcolor="#ffffff" allowscriptaccess="always" allowfullscreen="true" flashvars="config=http://www.animeshippuuden.com/xml.php?url=http://dc230.4shared.com/img/261579810/12e6e875/dlink__2Fdownload_2F261579810_2F12e6e875_3Ftsid_3D20100411-133409-3d47317f/preview.flv"/> Part 2 <embed src="http://i312.photobucket.com/albums/ll351/baokychen/player.swf" width="480" height="400" bgcolor="#ffffff" allowscriptaccess="always" allowfullscreen="true" flashvars="config=http://www.animeshippuuden.com/xml.php?url=http://dc230.4shared.com/img/261580266/460b860a/dlink__2Fdownload_2F261580266_2F460b860a_3Ftsid_3D20100411-133434-e86cfc61/preview.flv"/>';
    
        preg_match_all('/url=(.*?flv)/sim', $content, $result, PREG_PATTERN_ORDER);
        $result = $result[1];
    
        foreach( $result as $key => $url )
            printf('<p>Array %d - %s</p>', ( (int)$key + 1 ), $url );
    ?>
    
    PHP:
     
    ansi, Apr 19, 2010 IP
  6. bunbunx2

    bunbunx2 Peon

    Messages:
    613
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #6
    Thanks, job close . Winner = ansi
     
    bunbunx2, Apr 19, 2010 IP