If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > PHP > Search Text File for string

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-03-03, 22:11
aimjuncture.com aimjuncture.com is offline
Registered User
 
Join Date: Dec 2003
Location: New York
Posts: 2
Search Text File for string

I've looked around at many places..and haven't been able to find a funtion that I can understand for searching a text file.

Basically, I'm going to have a text file of names that my website currently supports....sorted in alphabetical order..IE:

ace
buck
max
thom
zoe

I want users to be able to request a new name to be added via a form, which I already have set up. But..when they request the name...I want the function to search through the text file and make sure that it's not already supported.

If the name is in the text file, I'd like to have it:
echo "The name you requested is already supported. Please click here.";

If the name is not in the text file, I'd like to have to have the function do approx. 5 other functions that I already have set up.

Any help would be greatly appreciated. Thanks!
Reply With Quote
  #2 (permalink)  
Old 12-04-03, 23:49
i4u_dev4 i4u_dev4 is offline
Registered User
 
Join Date: Oct 2003
Posts: 13
Smile think this will help you

// DB_dir is my physical path to that directory
// $dir is the directory name where all those files are located
// $pid is the file name ... for you

function img_exist($dir,$pid){

(file_exists(DB_dir."$dir/$pid.txt")){ return true; } else { return false; }

}
__________________
Manish Khanna
manish@i4u.com.au
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On