yehchge/yhighlight

highlight keywords

v1.0.1 2023-07-24 07:43 UTC

This package is auto-updated.

Last update: 2024-12-24 10:44:12 UTC


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>