Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

highlight search text in php

function highlightWords($text, $word){
    $text = preg_replace('#'. preg_quote($word) .'#i', '<span style="background-color: #F9F902;"></span>', $text);
    return $text;
}

//function calling
highlightWords($desc, $search_word);
 
PREVIOUS NEXT
Tagged: #highlight #search #text #php
ADD COMMENT
Topic
Name
3+3 =