highlight multiple keywords in search

前端 未结 8 480
庸人自扰
庸人自扰 2020-12-01 04:58

i\'m using this code to highlight search keywords:

function highlightWords($string, $word)
 {

        $string = str_replace($word, \"

        
8条回答
  •  南方客
    南方客 (楼主)
    2020-12-01 05:21

    as suggested by user187291, just change following code in order to get text highlighted with yellow background.

     return preg_replace($re, '$0', $text); 
    

提交回复
热议问题