Re: Search File

From: Date: Fri, 21 Nov 2003 18:05:17 +0000
Subject: Re: Search File
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-170605@lists.php.net to get a copy of this message
Vernon Webb wrote:
I'm trying to find a way to search text files in a directory using php. I've done some researching under the filesystem section on php.net but seem to have come up empty handed. Is there a way to do keyword searches on a txt file in a directory hopefully with some type of relevance ranking?
If you are on a unix system, you can just grep for the matches and then count the results. Send grep the list of files as input with your "keyword" -- and (I forget which option of grep it is man grep) grep will return the number of matches. Will probably be faster than reading each file using PHP. -- Burhan Khalid phplist[at]meidomus[dot]com http://www.meidomus.com ----------------------- "Documentation is like sex: when it is good, it is very, very good; and when it is bad, it is better than nothing."

« previous php.general (#170605) next »