url_shorten

Definition:
function url_shorten( $url ) {}

Shorten an URL, to be used as link text

Parameters

  • string $url

Source code

function url_shorten( $url ) {

	$short_url = str_replace( 'http://', '', stripslashes( $url ));

	$short_url = str_replace( 'www.', '', $short_url );

	if ('/' == substr( $short_url, -1 ))

		$short_url = substr( $short_url, 0, -1 );

	if ( strlen( $short_url ) > 35 )

		$short_url = substr( $short_url, 0, 32 ).'...';

	return $short_url;

}

3269

No comments yet... Be the first to leave a reply!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: