timostamm / text-truncation
dev-master
2017-10-03 16:11 UTC
Requires
- php: >=7.1
Requires (Dev)
- phpunit/phpunit: ~6.3
This package is auto-updated.
Last update: 2024-09-05 19:12:44 UTC
README
此实用程序可以将纯文本截断到最大长度。它能够识别段落、句子和单词,并使用它们以智能方式切割文本。
示例
// Setup a truncation for a maximum string length of 370 characters. // Use the Paragraph-Strategy, which tries to find a paragraph // within the first 370 characters, and falls back to a sentence or // a word. $t = new Truncation( 370, Truncation::STRATEGY_PARAGRAPH ); // Apply the truncation $txt = $t->truncate( $x );