function highlight($query, $content) { $point_dl = 100; $query = string::utf2win($query); $content = string::utf2win($content); $content = strip_tags($content); $content_st = $content_and = ''; $point = stripos($content, $query); $point1 = $point - $point_dl; if ($point1 < 0) { $point1 = 0; } else { $content_st = '...'; } $len = strlen($content); $point2 = $point + $point_dl; if ($point2 < $len) { $content_end = '...'; } else { $content_end = ''; } $content = $content_st . substr($content, $point1, $point2) . $content_end; $content = str_ireplace($query, '<span style="background-color: yellow; color: black;">' . $query . '</span>', $content); $query = string::win2utf($query); $content = string::highlight(string::win2utf($content), $query); return $content; }