Results 1 to 2 of 2
  1. #1
    Join Date
    Dec 2003
    New York

    Unanswered: 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:


    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!

  2. #2
    Join Date
    Oct 2003

    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts