gwolgamott Posted March 2, 2010 Share Posted March 2, 2010 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. Quote Link to comment https://forums.phpfreaks.com/topic/193890-search-algorithm-for-flat-file-folder-layout/ Share on other sites More sharing options...
salathe Posted March 2, 2010 Share Posted March 2, 2010 It would help if you detailed what you're searching through (just file names, file contents?), and what you're searching for (file names containing blah, files containing blah?). Quote Link to comment https://forums.phpfreaks.com/topic/193890-search-algorithm-for-flat-file-folder-layout/#findComment-1020408 Share on other sites More sharing options...
gwolgamott Posted March 2, 2010 Author Share Posted March 2, 2010 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 Quote Link to comment https://forums.phpfreaks.com/topic/193890-search-algorithm-for-flat-file-folder-layout/#findComment-1020425 Share on other sites More sharing options...
ferdi Posted March 2, 2010 Share Posted March 2, 2010 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? Quote Link to comment https://forums.phpfreaks.com/topic/193890-search-algorithm-for-flat-file-folder-layout/#findComment-1020426 Share on other sites More sharing options...
gwolgamott Posted March 2, 2010 Author Share Posted March 2, 2010 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. Quote Link to comment https://forums.phpfreaks.com/topic/193890-search-algorithm-for-flat-file-folder-layout/#findComment-1020431 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.