truncate - truncate string length
Truncate returns a portion of a string specified by the length parameter. It is used to limit the maximum length of a string by removing characters beyond the length parameter..
"To Truncate" = to shorten it, or cut part of it off.
Usage(s)
truncate ( $string , $length ) |
Returns part of a string that does not exeed the defined length |
Parameter(s)
$string |
The string to be shortened in length |
$length |
The maximum string length. Characters beyong this position will be removed. |
Example(s)
Shortening a Number
truncate(1234567890,5)
Returns the string 12345
|
Limit the length of a string
truncate(Himalaya,3)
Returns the first 3 characters "Him"
|
See also
strip - remove all whitespace
trim - remove whitespace
reverse - reverse a string
replace - string replace
leftpad - Left Padding
rightpad - Right Padding