PX : code

Search without SQL by Hamish Milne
Download this code


contents.txt
file.ext|Title
file.ext|Title

<?php
if ($_GET['searchstring']){echo "Search Results:<br><br>";
 
$contents "contents.txt";
 
$filearr file($contents);
 foreach(
$filearr as $line){
  list(
$checkfile$title) = split("\|"$line[0]);
  
$check file($checkfile);
  
$content=file_get_contents($checkfile);
  if (
eregi($_GET['searchstring'], $content)){
   echo 
"<font size='5'><a href='" $checkfile "'>" $title "</a></font><br>";
  }
  foreach(
$check as $checking){
   
$checkline strip_tags($checking);
   if(
eregi($_GET['searchstring'], $checkline)){
    
$word explode(" "$checkline);
    echo 
"...";
    foreach(
$word as $checkword){
     if (
eregi($_GET['searchstring'], $checkword)){
      echo 
"<b>$checkword </b>";
     }else{
      echo 
"$checkword ";
     }
    }
    echo
"...<br>";
   }
  }
  if (
eregi($_GET['searchstring'], $content)){
   echo 
"<br>";
  }
 }
}
?>

Comments or questions?
PX is running PHP 5.2.17
Thanks to Miranda Productions for hosting and bandwidth.
Use of any code from PX is at your own risk.