Skip to content

Instantly share code, notes, and snippets.

View aramk's full-sized avatar

Aram Kocharyan aramk

View GitHub Profile
@aramk
aramk / url_std.php
Created February 23, 2011 02:12
Simple URL Standardization that takes a user input URL and attempts to standardize it. If no URL scheme is given, defaults to http, also appends a forward slash if needed.
<?php
function url_std($url) {
extract(parse_url($url));
if ($scheme == '') {
$scheme = 'http';
}
$url = $scheme . "://" . $host . $path;
// Append a forward slash if needed
if ( !preg_match('|/$|', $url) ) {