- String::truncate(string $text, int $length=100, array $options)
- Parameters:
- $text (string) – The text to truncate.
- $length (int) – The length to trim to.
- $options (array) – An array of options to use.
- Example:
// called as TextHelper echo $this->Text->truncate( 'The killer crept forward and tripped on the rug.', 22, array( 'ellipsis' => '...', 'exact' => false ) ); // called as String App::uses('String', 'Utility'); echo String::truncate( 'The killer crept forward and tripped on the rug.', 22, array( 'ellipsis' => '...', 'exact' => false ) );
Output:
The killer crept...
Reference url: http://book.cakephp.org/