PHP code example of git-mz / tkmatch

1. Go to this page and download the library: Download git-mz/tkmatch 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/ */

    

git-mz / tkmatch example snippets


composer 

use tkmatch\main;

$main    = new Main();
$content = '我会脚踏云朵,哦不,是七彩云朵去娶你!';
$tags = [
    ['word' => '云朵',      'url' => 'www.yunduo.com'],
    ['word' => '七彩云朵',  'url' => 'www.qicaiyunduo.com'],
];

// 获取匹配到的tags
$res = $main::init()
     ->setTree($tags)
     ->getTagWord($content, $wordNum = 0);

// 替换匹配到的tags
$res = $main::init()
     ->setTree($tags)
     ->replace($content, $newclass = '', $replaceOne = 0);


v1.1.0
    getTagWord(String content, Int wordNum)
    //获取文本中匹配到的标签
    replace(String content, String newclass, Int replaceOne)
    //匹配替换文本中的标签