本文整理匯總了PHP中report_results函數的典型用法代碼示例。如果您正苦於以下問題:PHP report_results函數的具體用法?PHP report_results怎麽用?PHP report_results使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了report_results函數的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: main
function main()
{
if (strcmp('4.1.0', phpversion()) > 0) {
die("Error: PHP version 4.1.0 or above required!");
}
if (!($file = fopen("search.idx", "rb"))) {
die("Error: Search index file could NOT be opened!");
}
if (readHeader($file) != "DOXS") {
die("Error: Header of index file is invalid!");
}
$query = "";
if (array_key_exists("query", $_GET)) {
$query = $_GET["query"];
}
echo "<input class=\"search\" type=\"text\" name=\"query\" value=\"{$query}\" size=\"20\" accesskey=\"s\"/>\n";
echo "</span>\n";
echo "</form>\n";
echo "</div>\n";
$results = array();
$requiredWords = array();
$forbiddenWords = array();
$foundWords = array();
$word = strtok($query, " ");
while ($word) {
if ($word[0] == '+') {
$word = substr($word, 1);
$requiredWords[] = $word;
}
if ($word[0] == '-') {
$word = substr($word, 1);
$forbiddenWords[] = $word;
}
if (!in_array($word, $foundWords)) {
$foundWords[] = $word;
search($file, $word, $results);
}
$word = strtok(" ");
}
$docs = array();
combine_results($results, $docs);
// filter out documents with forbidden word or that do not contain
// required words
$filteredDocs = filter_results($docs, $requiredWords, $forbiddenWords);
// sort the results based on rank
$sorted = array();
sort_results($filteredDocs, $sorted);
// report results to the user
report_results($sorted);
fclose($file);
}
示例2: search
function search()
{
if (strcmp('4.1.0', phpversion()) > 0) {
die("Error: PHP version 4.1.0 or above required!");
}
$paths = paths();
$files = array();
$j = 0;
for ($i = 0; $i < sizeof($paths); $i++) {
if (!($f = @fopen($paths[$i] . "search.idx", "rb"))) {
die("Error: Search index file could NOT be opened!");
continue;
}
$files[$j++] = $f;
if (readHeader($f) != "DOXS") {
die("Error: Header of index file is invalid!");
}
}
$query = "";
if (array_key_exists("query", $_GET)) {
$query = $_GET["query"];
}
//end_form($query);
echo " \n<div class=\"searchresults\">\n";
$results = array();
$requiredWords = array();
$forbiddenWords = array();
$foundWords = array();
$word = strtok($query, " ");
while ($word) {
if ($word[0] == '+') {
$word = substr($word, 1);
$requiredWords[] = $word;
}
if ($word[0] == '-') {
$word = substr($word, 1);
$forbiddenWords[] = $word;
}
if (!in_array($word, $foundWords)) {
$foundWords[] = $word;
for ($i = 0; $i < sizeof($files); $i++) {
do_search($paths[$i], $files[$i], strtolower($word), $results);
}
}
$word = strtok(" ");
}
$docs = array();
combine_results($results, $docs);
// filter out documents with forbidden word or that do not contain
// required words
$filteredDocs = filter_results($docs, $requiredWords, $forbiddenWords);
// sort the results based on rank
$sorted = array();
sort_results($filteredDocs, $sorted);
// report results to the user
report_results($sorted);
echo "</div>\n";
foreach ($files as $file) {
fclose($file);
}
}
示例3: main
function main()
{
if (strcmp('4.1.0', phpversion()) > 0) {
die("Error: PHP version 4.1.0 or above required!");
}
if (!($file = fopen("search.idx", "rb"))) {
die("Error: Search index file could NOT be opened!");
}
if (readHeader($file) != "DOXS") {
die("Error: Header of index file is invalid!");
}
$query = "";
if (array_key_exists("query", $_GET)) {
$query = $_GET["query"];
}
end_form(ereg_replace("[^[:alnum:]:\\.\\t ]", " ", $query));
echo " \n<div class=\"searchresults\">\n";
$results = array();
$requiredWords = array();
$forbiddenWords = array();
$foundWords = array();
$word = strtok($query, " ");
while ($word) {
if ($word[0] == '+') {
$word = substr($word, 1);
$requiredWords[] = $word;
}
if ($word[0] == '-') {
$word = substr($word, 1);
$forbiddenWords[] = $word;
}
if (!in_array($word, $foundWords)) {
$foundWords[] = $word;
search($file, strtolower($word), $results);
}
$word = strtok(" ");
}
$docs = array();
combine_results($results, $docs);
// filter out documents with forbidden word or that do not contain
// required words
$filteredDocs = filter_results($docs, $requiredWords, $forbiddenWords);
// sort the results based on rank
$sorted = array();
sort_results($filteredDocs, $sorted);
// report results to the user
report_results($sorted);
echo "</div>\n";
fclose($file);
}
示例4: main
function main($idxfile)
{
if (strcmp('4.1.0', phpversion()) > 0) {
die("Error: PHP version 4.1.0 or above required!");
}
if (!($file = fopen($idxfile, "rb"))) {
die("Error: Search index file could NOT be opened!");
}
if (readHeader($file) != "DOXS") {
die("Error: Header of index file is invalid!");
}
$query = "";
if (array_key_exists("query", $_GET)) {
$query = $_GET["query"];
}
$results = array();
$requiredWords = array();
$forbiddenWords = array();
$foundWords = array();
$word = strtolower(strtok($query, " "));
while ($word) {
if ($word[0] == '+') {
$word = substr($word, 1);
$requiredWords[] = $word;
}
if ($word[0] == '-') {
$word = substr($word, 1);
$forbiddenWords[] = $word;
}
if (!in_array($word, $foundWords)) {
$foundWords[] = $word;
search($file, $word, $results);
}
$word = strtolower(strtok(" "));
}
$docs = array();
combine_results($results, $docs);
// filter out documents with forbidden word or that do not contain
// required words
$filteredDocs = filter_results($docs, $requiredWords, $forbiddenWords);
// normalize rankings so they are in the range [0-100]
normalize_ranking($filteredDocs);
// sort the results based on rank
$sorted = array();
sort_results($filteredDocs, $sorted);
// report results to the user
report_results($sorted);
fclose($file);
}