...

View Full Version : help! extracting url in array



thapame
06-10-2007, 02:30 AM
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

whizard
06-10-2007, 04:30 AM
Not sure I fully understand, but I hope this sets you in the right direction:


$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

thapame
06-10-2007, 05:03 AM
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...

whizard
06-10-2007, 02:27 PM
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



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum