\SearchWP\Highlighter
Sumário
\SearchWP\Highlighter pode destacar strings dentro de strings.
Uso Básico
Todo uso de \SearchWP\Highlighter requer dois parâmetros, um $haystack e um $needle. Um $needle dentro de um $haystack será envolvido em um elemento <mark class="searchwp-highlight"/>.
| <?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 ); |
Métodos
apply( string $haystack, string $needle)- Destaca o
$needleno$haystack
Hooks
Existem vários hooks disponíveis para modificar ainda mais o comportamento de \SearchWP\Highlighter:

