$url = 'http://username:password@hostname.com/dir/index.html?arg=value#anchor'; print_r( parse_url( $url ) ); // Array // ( // [scheme] => http // [host] => hostname.com // [user] => username // [pass] => password // [path] => /dir/index.html // [query] => arg=value // [fragment] => anchor // )