-
-
Save searchwpgists/7e6e836b054af619ea345a78ec84068e to your computer and use it in GitHub Desktop.
Basic usage of SearchWP's Highlighter class
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// @link https://searchwp.com/documentation/classes/searchwp-highlighter/ | |
$highlighter = new \SearchWP\Highlighter(); | |
$haystack = 'The best coffee you can find!'; | |
$needle = 'coffee'; | |
// Output: | |
// The best <mark class="searchwp-highlight">coffee</mark> you can find! | |
echo $highlighter->apply( $haystack, $needle ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment