Originally posted by Sharif
I don't think you understood what the script is supposed to do. Did you test the code you posted?
i realize you dont use a function called highlight_word
im implying for you to use your code there. im not getting specific, because you arent either.
again, if you want your results grouped together, and you just showed that you do want this by posting that example, you will need to decide on a strict set of rules of how you desire your code to behave.
what if they searched for 2 words, and 1 word was at the beggining of a long paragraph, yet the other was farther down the page?
should you highlight just 1 word? should you highlight both, showing ALL text in between(possibly pages of irrelevant text)?
should you break the text up and just show the relevant chunks around each word?
what if 2 word matches are next to each other? should you chunk this or not?
maybe this should depend on how much other text is between the 2 words?
if so, how should it depend?
i could think of a ton of these questions.....but YOU need to decide them, not us.
and then you said this
"i'd like to highlight those search terms in the text but not show teh entire blob... just cutoffs."
i dont see any "cutoffs" in your example, i see a single cutoff. there is a very large difference. again, decide upon a behavior you desire.
if this behavior is acceptable
... Note: Microsoft DirectX® 7.0 ........to play Midtown Madness......
then take a closer look at the last way i looped, as thats essentially what it will produce.