Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 1 of 1
  1. #1
    New Coder
    Join Date
    Jun 2012
    Thanked 0 Times in 0 Posts

    Problem with html_entity_decode

    I have added a search feature to my pages which contains text stored in a database.
    The text contains html entity code which replaced html tags added by tinymice plugin
    so before output it is run through the html_entity_decode function -

    Output method before adding search feature -

    PHP Code:
    echo html_entity_decode($row["message"], ENT_QUOTES'utf-8'); 
    I have also added the following function, which works but I do not fully understand, to highlight the words included in the user's search text

    PHP Code:
    function highlight($text$search) {    
    preg_match_all('@\[email protected]'$search$m);   
    $re '@\\b(' implode('|'$m[0]) . ')\\[email protected]';   
    preg_replace($re'<i class="hightlighttext">$0</i>'$text);} 
    I tried the following thinking it would remove the html and highlight the search words

    PHP Code:
     echo highlight(html_entity_decode($row['message'], ENT_QUOTES'utf-8'),$search); 
    However although the highlight still works the html tags continue to display.

    Is there a way to add the html_entity_decode somewhere within the actual highlight function?
    Last edited by maxwell5; Jan 12th, 2019 at 03:05 PM.


Tags for this Thread

Posting Permissions

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