yehchge / yhighlight
highlight keywords
v1.0.1
2023-07-24 07:43 UTC
Requires
- php: >=5.3.0
Suggests
- ext-mbstring: Required for UTF-8 string support
README
highlight keywords
Installation
composer require "yehchge/yhighlight"
Basic Usage
<?php declare(strict_types=1); include "vendor/autoload.php"; use yehchge\yhighlight\highlight; $hl = new highlight(); // default debug: false // $hl->setDebug(true); // default: // - <span class="hl"> // - </span> // $hl->setLeftHtml("<div style='background:yellow;'>"); // $hl->setRightHtml("</div>"); $title = "Do you know any funny jokes"; $keywords = array('fun', 'funny', 'joke'); $str = $hl->highlightKeywords($title, $keywords); echo $str;
<style> .hl { color: black; background-color: yellow; font-weight: bold; } </style>