You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

40 lines
1.1 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

<?php
namespace pinyin;
class Pinyin extends Base
{
/**
* 文字转拼音
* @param string $text 需要转拼音的文字
* @param string $options PINYIN_TONE--汉字转成带音调的拼音 PINYIN_UMLAUT_V--汉字转拼音中lv拼音为lyu使用此方法使用 v 代替 yu
* @date 2021-03-13
*/
function textToPinyin($text, $options = PINYIN_DEFAULT)
{
$pinyin_class = new \Overtrue\Pinyin\Pinyin();
$result = $pinyin_class->convert($text, $options);
return $result;
}
/**
* 句子转拼音(带标点符号)
* @param string $text 需要转拼音的文字
* @param string $options PINYIN_TONE--汉字转成带音调的拼音 PINYIN_UMLAUT_V--汉字转拼音中lv拼音为lyu使用此方法使用 v 代替 yu
* @param string $delimiter 分隔符
* @date 2021-03-13
*/
function sentenceToPinyin($text, $options = PINYIN_DEFAULT, $delimiter = '')
{
$pinyin_class = new \Overtrue\Pinyin\Pinyin();
$result = $pinyin_class->sentence($text, $delimiter, $options);
return $result;
}
}