Return to Snippet

Revision: 14488
at June 5, 2009 07:51 by iloveitaly


Initial Code
// this function processes a URL that 'should' be a full url (http://something.com/dfsdfs/)
// and makes sure it contains the correct format to be included into a href attribute
function processURLString($urlString) {
	$urlString = trim($urlString);
	
	if($urlString) {
		$urlString = preg_replace('/https?:\/\//', '', $urlString);
		$urlString = trim($urlString);
		$urlString  = 'http://'.$urlString;
	}
	
	return $urlString;
}

Initial URL

                                

Initial Description
this function processes a URL that 'should' be a full url (i.e. http://something.com/dfsdfs/)
and makes sure it contains http:// for easy inclusion as a link into a href attribute

Initial Title
Standardize URL String

Initial Tags
url, http, format

Initial Language
PHP