Something like this:
<?php
function search($keyword)
{
$results = false;
$lines = file('search_data.txt');
// escape characters which are sensitive to eregi()
$symbols = array('[', ']', '-', '(', ')');
$replace = array('\[', '\]', '\-', '\(', '\)');
$keyword = str_replace($symbols, $replace, $keyword);
foreach($lines as $line)
{
if(eregi($keyword, $line))
{
$line = str_replace($keyword, "<b>$keyword</b>", $line);
$results[] = $line;
}
}
return $results;
}
if(isset($_POST['submit']))
{
if(!empty($_POST['keyword']) && strlen($_POST['keyword']) > 3)
{
$keyword = $_POST['keyword'];
$search_results = search($keyword);
if(is_array($search_results))
{
echo 'The search term "<i><b>'. $keyword . '</b></i>" found ' . count($search_results) . ' search result(s):';
echo '<ol><li>' . implode('</li><li>', $search_results) . '</li></ol>';
}
else
{
echo 'No results was returned';
}
}
else
{
echo 'Invalid search term "<i><b>'. $_POST['keyword'] . '</b></i>"';
}
}
?>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
Search word: <input type="text" name="keyword" /> <input type="submit" name="submit" value="Search" />
</form>search_data.txt is the file which contains your search data.