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 comment