Forum Moderators: coopster

Message Too Old, No Replies

Can anyone suggest a Keyword to link script

was not able to search in this forum :-(

         

stardoc

2:10 am on Dec 28, 2005 (gmt 0)

10+ Year Member



Hello everyone, I am really sorry if this one has been asked before, but I was unable to search WebmasterWorld forums (!googlebot) for a possible answer.

I want a server side script which can covert the specified keywords to hyperlinks for one of my existing websites. Any script which can work as a censor/replace function should fit the bill, but I could not find any on google as well. Perhaps I am using the wrong keywords in my search. Can anyone recommend or give a clue to any such script.

Thanks in advance.

stardoc

1:53 pm on Dec 30, 2005 (gmt 0)

10+ Year Member



anyone? :-(

bmarx

5:22 am on Dec 31, 2005 (gmt 0)

10+ Year Member



I think I may not be understanding completely, but it sounds like a fairly simple task since you know what words you want to replace with links. My suggestion, something like:

$filename = "/usr/local/something.txt";
$handle = fopen($filename, "rw");
$page_text=fread($handle, filesize($filename));

//define keyword array
$keywords=array("keyword1","keyword2", etc...);

//define replacements for keyword array
$keywords_href=array("<A HREF=\"http://...\">keyword1<\/A>","<A HREF=\"http://...\">keyword2<\/A>", etc...).

//replace keywords with href links
$page_text_mod=str_replace($keywords,$keywords_href,$page_text);

fwrite($handle,$page_text_mod);
fclose($handle);

of course, you will have to be careful that none of your keywords are part of the html markup.

And no, I cannot suggest a keyword link script off the top of my head :)