SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Addict
    Join Date
    Apr 2002
    Posts
    281
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question about highlighting certain words

    You know how you do a search and the words you search for are highlighted or different color?

    or for example someone types a word like PHP and it will make a link automatically?

    how do you do that?

  2. #2
    SitePoint Addict s|k's Avatar
    Join Date
    Apr 2002
    Location
    Hilo, Hawai'i
    Posts
    266
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    you create a program that uses the highlight_string() function

    Please feel free to click on the second link in my signature the next time you have a question

  3. #3
    Making a better wheel silver trophy DR_LaRRY_PEpPeR's Avatar
    Join Date
    Jul 2001
    Location
    Missouri
    Posts
    3,428
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yeah, maybe he'd get a better answer in the manual, since you didn't give him one... the highlight_string() function is for highlighting PHP code (RTFM ).

    warjockey, you could use a regular expression to highlight the search word (not sure what you mean by link? that would depend on the application).

    PHP Code:
    $txt preg_replace("/($searchterm)/i"'<span style="color: red">$1</span>'$txt); 
    - Matt ** Ignore old signature for now... **
    Dr.BB - Highly optimized to be 2-3x faster than the "Big 3."
    "Do not enclose numeric values in quotes -- that is very non-standard and will only work on MySQL." - MattR

  4. #4
    SitePoint Addict s|k's Avatar
    Join Date
    Apr 2002
    Location
    Hilo, Hawai'i
    Posts
    266
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    whoops


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •