Return to Snippet

Revision: 43857
at April 1, 2011 07:29 by bluecap


Initial Code
function trimExtraChars($string, $max = 100, $tail = '...') {	
	if (strlen($string) > $max) {
		$string = substr($string, 0, $max) . $tail;
	}
	
	return $string;
}

Initial URL
http://www.bluecapwebdesign.com

Initial Description
If a string exceeds x characters (defaults to 100), trims the string to the first x characters and appends a tail to the end of the truncated string (defaults to an ellipsis).

Initial Title
Trim extra characters from string (truncate string)

Initial Tags
php

Initial Language
PHP