函数名称:IntlPartsIterator::getBreakIterator()
函数描述:获取当前IntlPartsIterator对象的断句迭代器
适用版本:PHP 7.0.0 及以上版本
用法:
创建IntlPartsIterator对象:
$iterator = new IntlPartsIterator('你好,世界!', 'root');
获取断句迭代器:
$breakIterator = $iterator->getBreakIterator();
使用断句迭代器:
while ($breakIterator->next() !== BreakIterator::DONE) {
$part = $iterator->getSubstring($breakIterator->getPrevious(), $breakIterator->current());
echo $part . PHP_EOL;
}
函数示例:
$text = 'Hello, world!';
$locale = 'en_US';
$iterator = new IntlPartsIterator($text, $locale);
$breakIterator = $iterator->getBreakIterator();
while ($breakIterator->next() !== BreakIterator::DONE) {
$part = $iterator->getSubstring($breakIterator->getPrevious(), $breakIterator->current());
echo $part . PHP_EOL;
}
输出结果:
Hello,
world!
注意事项: