Jump to content

Recommended Posts

Trying to figure out how to do a search the best way on a flat file setup?

 

Hey can anyone help me in the right direction. I need a search algorithm that I can use to filter through a series of folders and files looking at names and form numbers in specified folders?

 

I've usuaully used sql search algorithms but seems this should be simpler somehow or am I wrong on that when I'm just looking at a flat file setup... can I uses scandir to start this?

 

This folder is public viewing and read only btw.

It will search a folder full of subfolders, each containing files or photos.  The files are all named in a naming scheme such as QSFHR002_Holiday Request.doc  with the only exception being some photos being named with a scheme as such: lastname, firstname.jpeg

 

Since the files varies from .doc, .txt, .xls, .pdf, etc... I'm shooting just searching via partial name of any file similiar not the content due to the types that may be in there.

 

Thanks

You could use the glob() function, it's pattern based.

 

Saying you would like to search for files starting with "newyork", and having a .doc extension; this could work.

 

<?php

$dir './';
$files = glob('BLAH*.doc');

print_r($files); 
// output :
// newyork_vacation.doc, newyork_budget.doc, ...
?>

 

Or am I missing the point totally here?

No, you thinking along the right lines. That may be work, now how can I use glob() to search multiple file types? Since some file types are unqiue ones as well to some custom software they are using and can the pattern matching with glob be used to match part of the file names say for a file named: 23232_Bobba Luey.Htl  and I search for Boba can I get it to return that as one of the results I mean?

 

Or am I missing the point totally here?

 

I may answer my own question, since I've had limited use of glob() at this point so I'm going to look it up right now and see what I can do with it... but I'd still like input. thanks.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.