Truncates a string to the number of characters specified.
public static truncate ( string $string, integer $length, string $suffix = '...', string $encoding = null, boolean $asHtml = false ) : string | ||
$string | string | The string to truncate. |
$length | integer | How many characters from original string to include into truncated string. |
$suffix | string | String to append to the end of truncated string. |
$encoding | string | The charset to use, defaults to charset currently used by application. |
$asHtml | boolean | Whether to treat the string being truncated as HTML and preserve proper HTML tags. This parameter is available since version 2.0.1. |
Résultat | string | the truncated string. |