PHP code example of yljphp / chinese

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

    

yljphp / chinese example snippets



Yljphp\Simplified\Chinese;

$text = '中國人中国人123abc';

// 转为简体
var_dump(Chinese::simplified($text)); // 中国人中国人123abc

// 转为繁体
var_dump(Chinese::traditional($text)); // 中國人中國人123abc

// 转为以多字节字符串分隔的数组
var_dump(Chinese::toArray($text));

// 判断是否全部为中文
var_dump(Chinese::isChinese($text)); // bool(false)

// 判断是否包含中文
var_dump(Chinese::hasChinese($text)); // bool(true)