Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Jun 2007
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    help! extracting url in array

    I am working on some projects and need some on php. and this is best place for me ever.

    I need to extract range-url values in an array. The range-url may contains multiple range.

    Range-Url For eg.
    http://www.remotesite.com/images/img[01-15].jpg
    http://www.remotesite.com/images/img[01-15][20-23].jpg

    Extracted array value for http://www.remotesite.com/images/img[01-15].jpg
    http://www.remotesite.com/images/img01.jpg
    http://www.remotesite.com/images/img02.jpg
    http://www.remotesite.com/images/img03.jpg
    ..........................................
    http://www.remotesite.com/images/img15.jpg

    or for http://www.remotesite.com/images/img[01-15][20-23].jpg
    http://www.remotesite.com/images/img0120.jpg
    http://www.remotesite.com/images/img0221.jpg
    http://www.remotesite.com/images/img0322.jpg
    http://www.remotesite.com/images/img0423.jpg
    http://www.remotesite.com/images/img0520.jpg
    .........................

    Thanks in advance
    Last edited by thapame; 06-10-2007 at 02:46 AM.

  • #2
    Senior Coder whizard's Avatar
    Join Date
    Jan 2005
    Location
    Philadelphia, PA, USA
    Posts
    1,662
    Thanks
    14
    Thanked 76 Times in 76 Posts
    Not sure I fully understand, but I hope this sets you in the right direction:

    PHP Code:
    $url "http://www.remotesite.com/images/img[range].jpg";

    $url explode(".",$url);

    $url explode("/",$url[2]);

    $url $url[2];
    //Now $url = "img[range]"

    $url substr($url,3);
    //Now $url = [range] 
    HTH
    Dan
    PHP Tip: If you want to use short tags (<? or <?=$var) then make sure short_open_tag is set to "1". It really helps.

    Don't forget to save everyone time and mark your thread as Resolved :)

    "Also note that it is your responsibility to die() if necessary."

    DON'T USE THE MYSQL_ EXTENSION

  • #3
    New to the CF scene
    Join Date
    Jun 2007
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Spliting may be a good idea for this but how could we know the exact array position where range is located if the given $url value difers like http://www.remotesite.com/img[range].jpg, http://www.remotesite.com/contents/245/img[range].jpg etc...

  • #4
    Senior Coder whizard's Avatar
    Join Date
    Jan 2005
    Location
    Philadelphia, PA, USA
    Posts
    1,662
    Thanks
    14
    Thanked 76 Times in 76 Posts
    Ahh, I didn't realize that there were different file paths, since all the examples had the same path.

    Split it by slashes only, take the last section in the array, and then split that by the . for jpg, and you have your image name

    Dan
    PHP Tip: If you want to use short tags (<? or <?=$var) then make sure short_open_tag is set to "1". It really helps.

    Don't forget to save everyone time and mark your thread as Resolved :)

    "Also note that it is your responsibility to die() if necessary."

    DON'T USE THE MYSQL_ EXTENSION


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •