Searching flat files in PHP
How would I search a flatfile for a name? it is set out like this..
-----------------------------------
Adam Gajic|[email protected]
-----------------------------------
I don't want the email to be available in the search but printed as the result as well as the name.
Basically the person types a name to find someones email address.
Could someone help me?
Mark Hensler posted this at 09:02 — 22nd November 2001.
He has: 4,048 posts
Joined: Aug 2000
Why are you still using flat files? You should consider moving over to mySQL or other database program.
I don't have time to write out a whole script for you, but here are some functions you'll need:
reading the file: file(), fopen(), fread(), fclose()
parsing lines: strstr(), preg_match(), ereg()
Search functions can be rather complex depending on the requiremens. I'd suggest searching http://hotscripts.com and http://resourceindex.com to see if they have anything that will work for you.
Mark Hensler
If there is no answer on Google, then there is no question.
a_gajic posted this at 19:04 — 22nd November 2001.
They have: 71 posts
Joined: Aug 2001
It's just a small project that I am doing for myself, its just messing around really. I use MySQL most of the time but I haven't really used text files all that much so.. its just an opportunity
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.