Answers for "search result highlighting with php"

PHP
1

highlight search text in php

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

//function calling
highlightWords($desc, $search_word);
Posted by: Guest on September-11-2021

Browse Popular Code Answers by Language