Skip to content

Kirby 6.0.0

Str::short()

Shortens a string and adds an ellipsis if the string is too long

Str::short(string|null $string, int $length = 0, string $appendix = '…'): string

Parameters

Name Type Default Description
$string stringornull no default value
$length int 0 Final number of characters the string (excl. appendix) should have
$appendix string '…' The element, which should be added if the string is too long

Return type

string

Parent class

Kirby\Toolkit\Str

Examples

echo Str::short('This is a very, very, very long string', 10);
// output: This is a…

echo Str::short('This is a very, very, very long string', 10, '####');
// output: This i####