PHP code example of diszz / yii2-chinesepinyin

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

    

diszz / yii2-chinesepinyin example snippets

 php
php composer.phar diszz/yii2-chinesepinyin
 php
$Pinyin = new ChinesePinyin();
$str = '带声调的汉语拼音';
$ret = $Pinyin->TransformWithTone($str);
var_dump($ret);

echo '<br/>';
$str = '无声调的汉语拼音,凡芃团队';
$ret = $Pinyin->TransformWithoutTone($str);
var_dump($ret);

echo '<br/>';
$str = '首字母只包括汉字BuHanPinYin';
$ret = $Pinyin->TransformUcwordsOnlyChar($str);
var_dump($ret);

echo '<br/>';
$str = '首字母和其他字符如B区32号';
$ret = $Pinyin->TransformUcwords($str);
var_dump($ret);


string(40) "dài shēng diào de hàn yǔ pīn yīn "
string(38) "wushengdiaodehanyupinyinfanpengtuandui"
string(8) "SZMZBKHZ"
string(14) "szmhqtzfrBq32h"