-
I generally prefer XML for text files more complex than a usage log.
-
-
You can ask QUESTIONS about homework, but you should not be asking for us to do it for you. The difference is that you will post your code and ask for specific help, then we will see if there's some way to help you with what is giving you trouble-- not tell you where to start, what to do next and continue until it's done, and certainly not write it for you. There's no point, if you're in a class. If you don't do the work, you won't learn, and there's no reason we'd want extra homework.
I think the entire point of this assignment is to learn how to parse text files and that's actually useful to understand. If you want to go the advanced route, you can look into regex/regular expressions, but that can get complex.
If not, just start understanding the basics of reading files (it's not that hard-- just take some examples from php.net and work it out from there), then learn to work with strings.
If you aren't entirely confused by arrays, one easy way out is always to use the function called "explode()".
Of course cross-referencing will become the big complication. In a database you can actually just do a search. Here you'd have to load all of the data into variables to search through that. Arrays will help. Or you could just try to split the text file at the instance of the search term and find the closest related value (split at city, then find state, or whatever your goal might be).
For good reason, no one uses text files to search and parse all the time. They're fine for a once in a while thing, such as storage, but then for real use they are put into a database for searching. And you can output later to text files for storage, etc.
In other words, they're only parsed into and out of the database. After that they're used within the database. And it's much easier doing it once in a while just loading/unloading than actually using them.
Of course you can just deal with it by loading them into a database or set of complex variables just at the moment to search, but that's VERY VERY inefficient and I can guarantee that anyone giving out that kind of assignment is just testing your knowledge of the language/logic, and not hoping you'll ever use this for anything.
Anyway, good luck, and please keep in mind that we should be helping when you get stuck, not doing anything for you, especially when it comes to homework assignments.
Daniel -
Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum
-
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
Bookmarks