hanson/chinese

简繁体转换.

Maintainers

Details

github.com/Hanson/chinese

Source

Installs: 11 841

Dependents: 0

Suggesters: 0

Security: 0

Stars: 22

Watchers: 3

Forks: 16

dev-master 2018-09-06 18:23 UTC

This package is not auto-updated.

Last update: 2024-10-27 05:41:54 UTC


README

简繁体转换

安装方法

composer require hanson/chinese:dev-master

使用示例

<?php
require_once __DIR__.'/../vendor/autoload.php';

use Hanson\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)