View Single Post
Old 03-04-2005, 16:20   #10 (permalink)
Luke Redpath
Barney army!
 
Luke Redpath's Avatar
 
Join Date: Mar 2003
Location: London
Posts: 692
PHP Code:
$fileArray file($file);
if (
file_exists($file)) 

You need to do the file_exists check before opening it with file, so put $fileArray = file($file) inside your if statement.

PHP Code:
} else {
    echo 
"Error";    


Always best to try and be a bit more descriptive with your errors, so perhaps "Error: file not found" would be better.

Try this instead of the while loop:

PHP Code:
foreach($fileArray as $line) {
    if(
stristr($SearchString$line)) {
        print 
htmlentities($line);
    }
}


Have you not considered using the class I posted in my first reply? Its tested, documented and works. Might save you a lot of time, and the implementation is a piece of cake.
__________________
  Reply With Quote