<?php
function searchfiles($search,$dir) {
$results = array();
$n=0;
$opendir = opendir($dir);
while ($file = readdir($opendir)) {
if (in_array($file,array('.','..','otherfile.ext','....'))) continue;
//leave '.' and '..', and add any other files to skip... but try to keep mostly only searched files in this directory
if (!strpos($search,file_get_contents($dir.'/'.$file))) continue;
$array[$n] = $file;
$n++;
}
return $array;
}
if (isset($_POST['search']) )
print_r(searchfiles($_POST['term'], 'ord')); //set mydocs to your directory
//$search must be the text to match
else {
?>
<form action="" method="POST">
Search Term: <input type="text" name="term"> <input type="submit" name="search">
</form>
<?php
}
?>
Bookmarks