PHP code example of andares / adarts

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

    

andares / adarts example snippets



use Adarts\Dictionary;

// ...这里是从mysql中读取词条列表到$collection变量的1000行代码
$collection = MySQL::get();

$dict = new Dictionary();
foreach ($collection as $word) {
    $dict->add($word);
}
$dict->confirm();
{php}
// 假设“违法”和“犯规”两字在字典中
$limit  = 1;
$result = $dict->seek('违法犯规', $limit)->current();

// 这时$result结果只有违法
{php}
$limit  = 1;
$skip   = 2;
$result = $dict->seek('违法犯规', $limit, $skip)->current();

// 这时$result结果是犯规

$result = $dict->seek('get out! asshole!')->current();
if ($result) {
    throw new \LogicException('you could not say ' . $dict->getWordByState($result));
}

foreach ($dict->seek('get out! asshole!') as $result) {
    echo "you could not say ' . $dict->getWordByState($result);
}