您的位置:首页 > 编程语言 > PHP开发

好用的php代码片段收集

2016-11-07 17:22 148 查看
//关键字高亮

function highlighter_text($text, $words)

{

    $split_words = explode( " " , $words );

    foreach($split_words as $word)

    {

        $color = "#4285F4";

        $text = preg_replace("|($word)|Ui" ,

            "<span style=\"color:".$color.";\"><b>$1</b></span>" , $text );

    }

    return $text;

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  php