reverse function for parse_url (http://php.net/manual/en/function.parse-url.php)
<?php
if ( ! function_exists('build_url'))
{
/**
* @param array $parts
* @return string
*/
function build_url(array $parts)
{
$scheme = isset($parts['scheme']) ? ($parts['scheme'] . '://') : '';
$host = $parts['host'] ?? '';
$port = isset($parts['port']) ? (':' . $parts['port']) : '';
$user = $parts['user'] ?? '';
$pass = isset($parts['pass']) ? (':' . $parts['pass']) : '';
$pass = ($user || $pass) ? ($pass . '@') : '';
$path = $parts['path'] ?? '';
$query = isset($parts['query']) ? ('?' . $parts['query']) : '';
$fragment = isset($parts['fragment']) ? ('#' . $parts['fragment']) : '';
return implode('', [$scheme, $user, $pass, $host, $port, $path, $query, $fragment]);
}
}