William Ashworth wrote:
[color=blue]
> I have this glossary that was setup and I want to modify a bit.
> Here's how...
>
> ##############################
> printf($getWordArray["word"]);
> echo "</b></dt><dd>";
> printf($getWordArray["definition"]);
> echo "</dd><br>";
> }
> ##############################
>
> It out puts text like this...
>
> ##############################
> Term
> Definition here here here here here here here here here here
> here here here here here here here here.
> ##############################
>
> The whole idea is to have a sweet looking glossary like nobody else
> has done....here's my idea. I want the script to check the definition
> value BEFORE it's output to the browser window, and "look for" the
> "term" value to see if exists. If yes, then link the term to it's own
> special link such as that listed below...
>
> I want it to actually CHECK the $definition variable for the instance
> of ANY of $word variables in the database table. If yes, then link
> the word on output to be like this (where "underwriting" is the word
> that was recognized):
>
> ##############################
>
http://www.my-domain.com/glossary/gl...d=underwriting
> ....this would link to the term underwriting
> ##############################[/color]
You mean that, if a term on a page shows up in the glossay, you want it to
link to the glossary? Something like Astronomy.com does
(
http://astronomy.com/Content/Dynamic...407vgebk.asp)?
If so, and if your page text is coming from a database, you could
explode() your page text with a space, or other non-alpahbetic character,
then print each word individually, using isset() before you do to see if
it's in the array. If it is, write the anchor tag, print the word, then
close the anchor tag. You might want to unset() the array elements as
they're used, to avoid, say, 50 links to "underwriting" in the same page
(Astronomy.com does this). In this case, only the first instance would be
linked.
I'm not sure how efficient this method would be for long articles - use
caution.
Also note the drawbacks of automatically linking - links can sometimes be
out of context. For example, the sentence "Sagan was seeing Druyan for
several years before they married." on Astronomy.com would link "seeing"
to the astronomical definition, which refers to atmospheric conditions.
Good luck,
Shawn (in no way associated with Astronomy.com) :o)
--
Shawn Wilson
shawn@glassgiant.com http://www.glassgiant.com