Truncate string to given maximum length without breaking words and with no added visible extras
This is a shortcut to the truncate() sanitizer, sanitizing to nearest word with the more
option disabled and the collapseLinesWith
set to 1 space (rather than ellipsis).
Available since version 3.0.157.
Usage
// basic usage
$string = $sanitizer->trunc(string $str);
// usage with all arguments
$string = $sanitizer->trunc(string $str, $maxLength = 300, array $options = []);
Arguments
Name | Type(s) | Description |
---|---|---|
str | string | String to truncate |
maxLength (optional) | int, array | Maximum allowed length in characters, or substitute $options argument here |
options (optional) | array | See options for truncate() method or specify |
Return value
string
$sanitizer methods and properties
API reference based on ProcessWire core version 3.0.236