HektoR Posted January 21, 2009 Share Posted January 21, 2009 hi all so, i'm making script whic must get directories from range. i have main directory "MAIN"; in MAIN directory there are few dir" "01" , "02" , "03" , "03" , "04". and i want to, when i indicate range, for example: from "02" to "04" script must show me all directories in this range ... thats all. thank you Quote Link to comment https://forums.phpfreaks.com/topic/141739-solved-get-directories-from-range/ Share on other sites More sharing options...
MadTechie Posted January 21, 2009 Share Posted January 21, 2009 Thanks for letting us know.. but theirs no question.. so why post that in PHP Help ? Quote Link to comment https://forums.phpfreaks.com/topic/141739-solved-get-directories-from-range/#findComment-742037 Share on other sites More sharing options...
HektoR Posted January 21, 2009 Author Share Posted January 21, 2009 thank you too for this most helpful post. why? because i want to make this in php and i don't have any idea . this is too hard to understand ? i think NO. if you don't want to help, stop posting here please. Quote Link to comment https://forums.phpfreaks.com/topic/141739-solved-get-directories-from-range/#findComment-742042 Share on other sites More sharing options...
MadTechie Posted January 21, 2009 Share Posted January 21, 2009 I did want to help, but not anymore good luck Quote Link to comment https://forums.phpfreaks.com/topic/141739-solved-get-directories-from-range/#findComment-742045 Share on other sites More sharing options...
HektoR Posted January 21, 2009 Author Share Posted January 21, 2009 thank you Quote Link to comment https://forums.phpfreaks.com/topic/141739-solved-get-directories-from-range/#findComment-742055 Share on other sites More sharing options...
HektoR Posted January 21, 2009 Author Share Posted January 21, 2009 soo, any ideas for making that script? Quote Link to comment https://forums.phpfreaks.com/topic/141739-solved-get-directories-from-range/#findComment-742064 Share on other sites More sharing options...
MadTechie Posted January 21, 2009 Share Posted January 21, 2009 So if for example, if you have folder 1 2 5 6 9 10 11 and done dirrange(2,10) you want it to return 2 5 6 9 10 right ? if so you could try something like this <?php $R = range(2,10); $folder = array(); $Path = "path/to/folders/"; foreach ($R as $V) { if(is_dir($Path.$V)) $folder[] = $V; } echo "<pre>"; print_r($folder) ?> Quote Link to comment https://forums.phpfreaks.com/topic/141739-solved-get-directories-from-range/#findComment-742078 Share on other sites More sharing options...
HektoR Posted January 21, 2009 Author Share Posted January 21, 2009 no, if range is from 2 to 10 it must return 2 3 4 5 6 7 8 9 10 Quote Link to comment https://forums.phpfreaks.com/topic/141739-solved-get-directories-from-range/#findComment-742081 Share on other sites More sharing options...
MadTechie Posted January 21, 2009 Share Posted January 21, 2009 even if the folders are missing ? what do you mean by "get directories" i assumed to meant get the names of all existing directories within a range Quote Link to comment https://forums.phpfreaks.com/topic/141739-solved-get-directories-from-range/#findComment-742085 Share on other sites More sharing options...
Mark Baker Posted January 21, 2009 Share Posted January 21, 2009 no, if range is from 2 to 10 it must return 2 3 4 5 6 7 8 9 10 This has nothing to do with directories at all: $rangeStart = 2; $rangeEnd = 10; print_r(range($rangeStart,$rangeEnd)); Quote Link to comment https://forums.phpfreaks.com/topic/141739-solved-get-directories-from-range/#findComment-742087 Share on other sites More sharing options...
HektoR Posted January 21, 2009 Author Share Posted January 21, 2009 MadTechie it was my mistake. your code is working. but what i can do when folder names is ,like : 01 02 03 04 05 06 07 08 ?? Quote Link to comment https://forums.phpfreaks.com/topic/141739-solved-get-directories-from-range/#findComment-742096 Share on other sites More sharing options...
MadTechie Posted January 21, 2009 Share Posted January 21, 2009 sprintf EG <?php $R = range(2,10); $folder = array(); foreach ($R as $V) { $V= sprintf("%02s",$V); //add the 0 for the 1to9 if(is_dir($V)) { $folder[] = $V; echo "FOUND: $V<br>"; }else{ echo "NOT FOUND: $V<br>"; } } echo "<pre>"; print_r($folder) ?> EDIT: missed a / on the comment Quote Link to comment https://forums.phpfreaks.com/topic/141739-solved-get-directories-from-range/#findComment-742102 Share on other sites More sharing options...
HektoR Posted January 21, 2009 Author Share Posted January 21, 2009 Solved ! thank you very much ! Quote Link to comment https://forums.phpfreaks.com/topic/141739-solved-get-directories-from-range/#findComment-742120 Share on other sites More sharing options...
MadTechie Posted January 21, 2009 Share Posted January 21, 2009 Your welcome.. Can you please click the solved button, bottom left (i think) Quote Link to comment https://forums.phpfreaks.com/topic/141739-solved-get-directories-from-range/#findComment-742126 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.