\n";
$haves[] = trim(ereg_replace("^\ ", " ", $objects[$j]));
}
/* If the object starts in "-" it goes on the havenots[]. */
if ( substr ( $objects[$j], 0, 1 ) == "-" ) {
$havenots[] = trim(ereg_replace("^-", " ", $objects[$j]));
//$j ;
}
/* END CHECKING THE CURRENT OBJECT */
/* BEGIN CHECKING THE NEXT OBJECT */
if ( $objects[$j 1] == "AND" ) {
/* Hop onto the "AND". */
$j ;
if ( ! ereg("^[\ -]", $objects[$j-1]) ) {
$haves[] = $objects[$j-1];
}
else { /* Just hang tight. */ }
$haves[] = $objects[$j 1];
while ( $objects[$j 2] == "OR" ) {
// Hop on top of the OR.
$j = $j 2;
$haves[] = $objects[$j 1];
}
}
elseif ( $objects[$j 1] == "NOT") {
/* Hop on the NOT. */
$j ;
$alternates[] = $objects[$j-1];
$havenots[] = $objects[$j 1];
while ( $objects[$j 2] == "OR" ) {
// Hop on top of the OR.
$j = $j 2;
$havenots[] = $objects[$j 1];
}
}
elseif ( $objects[$j 1] == "OR" ) {
/* Hop onto the OR. */
$j ;
$alternates[] = $objects[$j-1];
$alternates[] = $objects[$j 1];
}
else {
/* It's just a regular word, throw it on the alternates. */
if ( ( substr($objects[$j], 0, 1) != " " ) && ( substr($objects[$j], 0, 1) != "-" ) && ( $objects[$j-1] != "AND" ) && ( $objects[$j-1] != "NOT" ) ) {
$alternates[] = $objects[$j];
}
}
}
/* END CHECKING THE NEXT OBJECT */
/******** BEGIN FILTER ********/
/* Sort the arrays. */
sort ( $haves );
sort ( $havenots );
sort ( $alternates );
/* End sorting. */
/* Remove duplicates within each array. */
$haves = flush_dupes($haves);
$havenots = flush_dupes($havenots);
$alternates = flush_dupes($alternates);
/* End removing duplicates within each array. */
/* Eliminate all of the duplicated values between the haves and alternates array. */
$alternates = rank_arrays ( $haves, $alternates );
$alternates = rank_arrays ( $havenots, $alternates );
$haves = rank_arrays ( $havenots, $haves );
/* End eliminating duplicates between arrays. */
/******** END FILTER ********/
/* Display the results of the search. */
print "Search for:\n";
print "Objects:</b>\n";
for($i=0; $i..$objects[$i]..</li>\n";
}
print "</ul>\n\n";
print "Records with:</b>\n";
for($i=0; $i$haves[$i]</li>\n";
}
print "</ul>\n\n";
print "Records without:</b>\n";
for($l=0; $l$havenots[$l]</li>\n";
}
print "</ul>\n\n";
print "Records that have any of the following:</b>\n\n";
for($t=0; $t$alternates[$t]</li>\n";
}
print "</ul>\n\n";
exit;
/*** EOF ***/
}
// Example:
// < form action="this script" method="post" >
?>