PHP code example of writecrow / highlighter

1. Go to this page and download the library: Download writecrow/highlighter library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

writecrow / highlighter example snippets


print HighlightExcerpt::highlight('Round the rugged rock,' ['the']);
// Will print 'Round <mark>the</mark> rugged rock'

print HighlightExcerpt::highlight('Round the rugged rock,' ['the', 'rock']);
// Will print 'Round <mark>the</mark> rugged <mark>rock</mark>'

print HighlightExcerpt::highlight('Round the rugged rock,' ['ro', '"round"']);
// Will print 'Round the rugged rock', since `ro` is present, 
// but only a word partial,
// and `round` is present, but double-quotes indicate case-sensitivity
// so `round` != `Round`


print HighlightExcerpt::highlight('Round the rugged rock,' ['the'], 300);
// Would limit the excerpt to 300 characters