PHPBuilder - Php Dot it



RSS Twitter
Snippets Algorithms

Php Dot it

by: Eugene Wee
|
April 30, 2006

Version: 1.2

Type: Function

Category: Algorithms

License: GNU General Public License

Description: A Simple routine to cut a string . If the string has a number of characters higher than desired, the function returns the number of characters desired and 3 dots(or more, as you modify the function). If the string has a number of characters lower than the max. desired the function returns the full string...! Example: echo lefts( "Oh My God!", 5 ); returns : Oh My ... echo lefts( "Oh My God!", 20 ); returns : Oh My God!



function rightDotPad($input, $length) {
	if (strlen($input) > $length) {
		return substr($input, 0, $length) . '...';
	}
	return $input;
}

Comment and Contribute

Your comment has been submitted and is pending approval.

Author:
Eugene Wee

Comment:



Comment:

(Maximum characters: 1200). You have characters left.