4WebHelp
 FAQ  •  Search  •  User Groups  •  Forum Admins  •  Smilies List  •  Statistics  •  Rules   •  Login   •  Register
Toggle Navigation Menu

 PHP: Help with File Listing
Post New TopicReply to Topic
View Previous Topic Print this topic View Next Topic
Author Message
brainfuelmedia
Junior WebHelper
Junior WebHelper


Joined: 28 May 2002
Posts: 5
Location: Canada

PostPosted: Thu May 30, 2002 6:47 pm (21 years, 10 months ago) Reply with QuoteBack to Top

I have a file named:

msds_Calcium_6%.pdf

in a directory on my server. I want to be able to produce a directory listing where it only lists files that are of type "msds", and named "Calcium 6%". There could be additional files under the "Calcium 6%" product name (e.g. Calcium 6% Advantage) that I would also like the script to show on the web page.

My idea is to have PHP check a directory first for any files listed as "msds", then check to see if they also contain the characters, "Calcium 6%".

Is there a PHP function that looks for a capital letter then checks all the characters after that to a specified string length? This way I could look through the file name until it reaches the first capital letter, check the characters after that, and see if it is a match. If it is a match, then it would print all the files that match the parameter specified.

Thanks for any help,
Ryan
OfflineView User's ProfileFind all posts by brainfuelmediaSend Personal MessageVisit Poster's WebsiteYahoo Messenger
ScottBP
Junior WebHelper
Junior WebHelper


Joined: 06 Jul 2002
Posts: 1

PostPosted: Sat Jul 06, 2002 10:17 pm (21 years, 9 months ago) Reply with QuoteBack to Top

Here is some code I have used in the past, it should get you pretty close.

//Get listing
$handle=opendir("directory");
while($file=readdir($handle)){
$retVal[count($retVal)]=$file;
}

//Clean up and sort
closedir($handle);
sort($retVal);

// Build List
for($i=0; $i<=count($retVal); $i++){
// Check for blank entries
if ((!ereg("[.]",$retVal[$i])) && (!ereg("[ ]",$retVal[$i])) && $retVal[$i]!="") {
if( <insert criteria here>){
<do something with entry>
}
}
}



Good Luck,

Scott


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Scott B. Pier
Amalla International
For All Your Internet Needs
ScottBP@amalla.com
http://www.amalla.com
949-661-6144
OfflineView User's ProfileFind all posts by ScottBPSend Personal Message
Display posts from previous:      
Post New TopicReply to Topic
View Previous Topic Print this topic View Next Topic


 Jump to:   




You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot edit your posts in this forum.
You cannot delete your posts in this forum.
You cannot vote in polls in this forum.


Page generation time: 0.21848 seconds :: 18 queries executed :: All Times are GMT
Powered by phpBB 2.0 © 2001, 2002 phpBB Group :: Based on an FI Theme