
08-19-06, 07:09 AM
|
 |
Community Leader
|
|
Join Date: Sep 2005
Location: Spain
Posts: 8,074
Thanks: 11
Thanked 88 Times in 83 Posts
|
|
A bit too late... but anyways.
PHP Code:
<?php
$search = $_POST['search'];
$file = file('data.txt');
$keys = preg_split('/[\s,]+/', preg_replace('/(^\s+|\#|\/|\'|\"|\~|\^|\.|\+|\$|\s+$)/', '', $search) );
if (sizeof($keys) > 5)
{
die("Please enter less keywords");
}
$pattern = '/('. implode('|', $keys) .')/i';
$matches = array();
foreach ($file as $line => $data)
{
list($month, $day, $year, $info) = explode('|', trim($data) );
if (preg_match($pattern, $info))
{
$matches[$year][] = preg_replace($pattern, '<span style="color:red;">$1</span>', $info);
}
}
ksort($matches);
print_r($matches);
?>
Last edited by nico_swd; 08-19-06 at 07:20 AM.
|