Version: v0.8.1 - Beta.  We welcome contributors & feedback.

String.limit

limit($numCharacters, $ending='…') -> string

Description

If the string length is larger than numCharacters, truncate the string and append ending.

Common punctuation characters will be trimmed from the end before ending is added.

$longString = 'This is a moderately long phrase.'
$longString.limit(20)
//= 'This is a moderately…'

See Also