Question
OT: Highlighting keywords in content - PHP
I have a document displayed on a page and I want to highlight
keywords in
the document's text. My simple (and usually befuddled) mind tells me to
begin attempting this in the following way -
1. Load the document contents into an array (with explode).
2. Load the keywords list into an array.
3. For each word in the document (i.e., element in the contents array),
scan the keyword list for a match, and if there is a match, add a <span
class="highlight"></span> around it.
4. Display the document.
I want to do it this way to accommodate a dynamic keyword list.
The documents themselves are pretty short - maybe 5 - 6 paragraphs.
Am I thinking about this the right way?
--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.dreamweavermx-templates.com - Template Triage!
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes
==================
the document's text. My simple (and usually befuddled) mind tells me to
begin attempting this in the following way -
1. Load the document contents into an array (with explode).
2. Load the keywords list into an array.
3. For each word in the document (i.e., element in the contents array),
scan the keyword list for a match, and if there is a match, add a <span
class="highlight"></span> around it.
4. Display the document.
I want to do it this way to accommodate a dynamic keyword list.
The documents themselves are pretty short - maybe 5 - 6 paragraphs.
Am I thinking about this the right way?
--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.dreamweavermx-templates.com - Template Triage!
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes
==================
