Parsing a file name

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
emsenn
Forum Newbie
Posts: 1
Joined: Sun Jan 18, 2009 5:09 pm

Parsing a file name

Post by emsenn »

I'm working on a script that will be used by a small digital library to rename their files based on a classification schedule. One thing that could greatly speed up the transition is if the script could recommend the basic call numbers for a topic, based on a file's name. Perhaps an example would be helpful:

A file's name is C++, a Beginners Guide.txt. I want to read the string "C++" from that, and based on that recommend a number (004.1.1064). A simple array would work, however there will be some numbers that have more than one keyword tied to them. For example, Metaphysics and Metaphysical both have the same call number.

I'm interested in how to approach a function that would take the file name and find the number based on that - I however have very little clue on what to do beyond that, and any help would be greatly appreciated.
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Re: Parsing a file name

Post by Burrito »

if it's going to use any kind of standardization in the filename construction, you could use substr() otherwise you'll want to write a regular expression to extract the info you need from the names with preg_match()
Post Reply