yupe\helpers\YText::highlightPhrase PHP Method

highlightPhrase() public static method

Выделить фразу в тексте
public static highlightPhrase ( $str, $phrase, $tag_open = '<strong>', $tag_close = '</strong>' ) : string
return string - строка с выделенными фразами
    public static function highlightPhrase($str, $phrase, $tag_open = '<strong>', $tag_close = '</strong>')
    {
        if ($str == '') {
            return '';
        }
        if ($phrase != '') {
            return preg_replace('/(' . preg_quote($phrase, '/') . ')/i', $tag_open . "\\1" . $tag_close, $str);
        }
        return $str;
    }