trim_characters() 공개 정적인 메소드

This function can be useful for excerpt of the post As opposed to wp_trim_words trims characters that makes text to take the same amount of space in each post for example
부터: 1.2.0
저자: @CROSP
public static trim_characters ( string $text, integer $num_chars = 60, string | null $more = null ) : string
$text string Text to trim.
$num_chars integer Number of characters. Default is 60.
$more string | null Optional. What to append if $text needs to be trimmed. Default '…'.
리턴 string trimmed text.
예제 #1
0
 function testTrimCharacters()
 {
     $text = "Sometimes you need to do such weird things like remove all comments from your project.";
     $trimmed = \Timber\TextHelper::trim_characters($text, 20);
     $this->assertEquals("Sometimes yo…", $trimmed);
 }