truncate() public static method

Truncates a string.
public static truncate ( string $value, array $format = [] ) : string
$value string Value
$format array Default format is `array('length' => 80, 'etc' => '...', 'break_words' => false)`
return string
コード例 #1
0
ファイル: formatter_test.php プロジェクト: staabm/redaxo
 public function testTruncate()
 {
     $value = 'very loooooong text lala';
     $format = ['length' => 10, 'etc' => ' usw.', 'break_words' => true];
     $this->assertEquals('very  usw.', rex_formatter::truncate($value, $format));
     // XXX hmm seems not to be correct
     $format = ['length' => 10, 'etc' => ' usw.', 'break_words' => false];
     $this->assertEquals('very usw.', rex_formatter::truncate($value, $format));
 }