|
Author |
Message |
brainfuelmedia
Junior WebHelper
Joined: 28 May 2002
Posts: 5
Location: Canada
|
Posted:
Thu May 30, 2002 6:47 pm (21 years, 11 months ago) |
|
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 |
|
|
|
|
ScottBP
Junior WebHelper
Joined: 06 Jul 2002
Posts: 1
|
Posted:
Sat Jul 06, 2002 10:17 pm (21 years, 9 months ago) |
|
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 |
|
|
|
|
|
|
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.158695 seconds :: 19 queries executed :: All Times are GMT
Powered by phpBB 2.0
© 2001, 2002 phpBB Group :: Based on an FI Theme
| |