PHP code example of u7aro / tinysegmenter-php

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

    

u7aro / tinysegmenter-php example snippets


use U7aro\TinySegmenter\TinySegmenter;

$text = '私の名前は中野ではありません';
$result = TinySegmenter::segment($text);

var_dump($result);
// array(10) {
//   [0]=>
//   string(3) "私"
//   [1]=>
//   string(3) "の"
//   [2]=>
//   string(6) "名前"
//   [3]=>
//   string(3) "は"
//   [4]=>
//   string(6) "中野"
//   [5]=>
//   string(3) "で"
//   [6]=>
//   string(3) "は"
//   [7]=>
//   string(6) "あり"
//   [8]=>
//   string(6) "ませ"
//   [9]=>
//   string(3) "ん"
// }
bash
composer