This first script will take all of the words in your file and hyperlink them. I am guessing this is what you do not want, so let's skip to the next script.
PHP Code:
<?php
$text = file_get_contents("http://www.mysite.com/the-includes/search.txt",NULL);
$text=str_replace('[keywords]:','',$text);
$text=str_replace("\r\n"," ",$text);
$text=str_replace("\n",' ',$text);
$text=preg_replace('/[^a-zA-Z\s]/','',$text);
$text=preg_replace('/(\s){2,}/',' ',$text);
$text=strtolower($text);
$text=explode(" ",$text);
$out=array_count_values($text);
arsort($out);
$out=array_slice($out,0,40);
$crotz="";
$out=array_keys($out);
foreach ($out as $value) {
$crotz .= '<a class="latest" href="';
$crotz .= "http://".www.mysite.com."/index.php?search=".urlencode($value)."&source=All";
$crotz .= "\">".htmlspecialchars($value)."</a>";
$crotz .= ", ";
}
echo"$crotz";
?>
The following is similar, but will take each set of terms like "black eyed peas" and hyperlink the grouped words.
PHP Code:
<?php
$text = file_get_contents("http://www.mysite.com/the-includes/search.txt",NULL);
$text=str_replace('[keywords]:','<br>',$text);
$text=strtolower($text);
$text=explode("<br>",$text);
$out=array_count_values($text);
arsort($out);
$out=array_slice($out,0,40);
$crotz="";
$out=array_keys($out);
foreach ($out as $value) {
$crotz .= '<a class="latest" href="';
$crotz .= "http://".www.mysite.com."/index.php?search=".urlencode($value)."&source=All";
$crotz .= "\">".htmlspecialchars($value)."</a>";
$crotz .= ", ";
}
echo"$crotz";
?>
This second script uses [keywords]: as the delimiter. In retrospect I can see one or two ways the second script could be improved a bit more, but it should work well enough as is.
Bookmarks