Last active
November 11, 2020 13:48
-
-
Save jchristopher/7c30c421a677dc0beb6f1f0324cedb09 to your computer and use it in GitHub Desktop.
Basic usage of SearchWP's Highlighter class
This file contains hidden or 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 | |
$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