1.20.x link.module | _link_parse_url($url) |
Because parse_url doesn't work with relative URLs.
Parameters
string $url: URL to parse.
Return value
array: Array of URL pieces - only 'url', 'query', and 'fragment'.
File
- modules/
link/ link.module, line 645 - Defines simple link field types.
Code
function _link_parse_url($url) {
$url_parts = array();
// Separate out the anchor, if any.
if (strpos($url, '#') !== FALSE) {
$url_parts['fragment'] = substr($url, strpos($url, '#') + 1);
$url = substr($url, 0, strpos($url, '#'));
}
// Separate out the query string, if any.
if (strpos($url, '?') !== FALSE) {
$query = substr($url, strpos($url, '?') + 1);
$url_parts['query'] = _link_parse_str($query);
$url = substr($url, 0, strpos($url, '?'));
}
$url_parts['url'] = $url;
return $url_parts;
}