PHP code example of meshell / ffi-pinyin
1. Go to this page and download the library: Download meshell/ffi-pinyin 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/ */
meshell / ffi-pinyin example snippets
FastFFI\Pinyin\Pinyin::new();
echo "无音标: ", $py->plain("中国人...😄😄👩", false, false), "\n";
echo "音标: ", $py->tone("中国人", false, false), "\n";
echo "音标数字: ", $py->toneNum("中国人", false, false), "\n";
echo "音标数字结尾: ", $py->toneNumEnd("中国人", false, false), "\n";
echo "首字母: ", $py->letter("中国人", false, false), "\n";
echo "音标转换模式: ", $py->tone("中国人😄😄", true, false), "\n";
echo "音标多音词模式: ", $py->tone("中国人", false, true), "\n";
echo "音标未识别跳过: ", $py->plain("PHP永远滴神,rust永远的神", true, false, '-'), "\n";
echo "音标未识别不分隔: ", $py->plain("PHP永远滴神,rust永远的神", false, false, '-', true), "\n";
var_export($py->plainArray("PHP永远滴神,rust永远的神", false, false, true));
text
无音标: zhong guo ren . . . 😄 😄 👩
音标: zhōng guó rén
音标数字: zho1ng guo2 re2n
音标数字结尾: zhong1 guo2 ren2
首字母: z g r
音标转换模式: zhōng guó rén
音标多音词模式: zhōng:zhòng guó rén
音标未识别跳过: yong-yuan-di-shen-yong-yuan-de-shen
音标未识别不分隔: PHP-yong-yuan-di-shen-,rust-yong-yuan-de-shen
array (
0 => 'PHP',
1 => 'yong',
2 => 'yuan',
3 => 'di',
4 => 'shen',
5 => ',rust',
6 => 'yong',
7 => 'yuan',
8 => 'de',
9 => 'shen',
)
text
\Bench
benchFFI................................I0 [μ Mo]/r: 1.599 1.599 (ms) [μSD μRSD]/r: 0.000ms 0.00%
benchNative.............................I0 [μ Mo]/r: 19.783 19.783 (ms) [μSD μRSD]/r: 0.000ms 0.00%
benchNativeMemory.......................I0 [μ Mo]/r: 21.160 21.160 (ms) [μSD μRSD]/r: 0.000ms 0.00%
benchNativeGenerator....................I0 [μ Mo]/r: 125.524 125.524 (ms) [μSD μRSD]/r: 0.000ms 0.00%