I have come across a new problem with my program, in which the pattern I have provided it only opens and read's .txt files I assume this is because this is the first on the list.
PHP Code:
function opening($file) {
$pattern = "(\.txt$)| (\.php$)| (\.html$)| (\.htm$)"; // pattern to match if(eregi($pattern, $file)){ $file_handle = fopen($file, "r"); $contents = file($file); while (!feof($file_handle)){ $data = fgets($file_handle); $words = explode(' ' , $data); $duplicates = array_unique($words); sort($duplicates); if(is_bool(strpos($stoplist, '$duplicates[i]'))) { foreach($duplicates as $word) { $word = serialize($word); $sql = "INSERT INTO webdata VALUES('$file','$word')"; if (mysql_query($sql)) { print "successful <p>"; } } }
} } else { echo "Cant open that file type <p>"; } }
How can I fix this so it opens all the provided file extensions?
|