$title

View the PHP code used.
 

HTML; $headers = ''; $fp = fopen('ffdd4.txt','r'); if (!$fp) {echo 'ERROR: Unable to open file.
First Name Surname City Points Vehicle Colour Age
'; exit;} $row = 0; $columns = 7; while (!feof($fp)) { $line = fgets($fp,1024); //use 2048 if very long lines $field[$row] = explode('|', $line); $row++; } fclose($fp); /* sort($field); reset($field); */ $arrays = count($field) - 1; $loop = -1; $columnsminusone = $columns - 1; $once = 'no'; $found = 'no'; $search = strtolower($original); $count = 0; $highlight1 = ''; $highlight2 = ''; while ($loop < $arrays) { $loop++; $cell = 0; while ($cell < $columns) { $field2 = strtolower($field[$loop][$cell]); if (strstr($field2,$search)) { $found = 'yes'; $count++; if ($once == 'no') { $once = 'yes'; echo '

\''.$original.'\' was found in the following lines of the database:

'.$headers; } //prepare to cut up string to add highlight $fieldlength = strlen($field2); $searchlength = strlen($search); $pos = strpos($field2, $search); $stringend = $searchlength + $pos; $slice1 = substr($field[$loop][$cell], 0, $pos); $slice2 = substr($field[$loop][$cell], $pos, $searchlength); $slice3 = substr($field[$loop][$cell], $stringend); $field[$loop][$cell] = $slice1.$highlight1.$slice2.$highlight2.$slice3; echo ' '.$field[$loop][0].' '.$field[$loop][1].' '.$field[$loop][2].' '.$field[$loop][3].' '.$field[$loop][4].' '.$field[$loop][5].' '.$field[$loop][6].' '; break; } $cell++; } } if ($found == 'no') {echo '

\''.$original.'\' was not found in the database.

';} echo '

Number of searches found: '.$count.'

15 January 2009 · Last updated: '.date('jS F Y', getlastmod()); ?> · A Design Detector production · About The Demo · Comments