Builds an URL-string from a url-components-array.
This is a counterpart function to hublify.urlInfo(...).
It supports building multi-dimensional-query-string /-arrays.
Syntax
urlBuild(array $urlInfo, $withHost = false): string
Parameter
@param array $urlInfo An array containing url-components to build.
Return
Returns an array containing the keys (only set if their parts were present in the $url):
- scheme - string
- host - string
- port - string|number
- user - string
- pass - string
- path - string
- params - array The query-string, everything after the question mark "?", parsed into an (multi-dimensional) array.
- fragment - string Everything after the anchor-hash "#"
Examples
To get all components of the currently rendered and called url:
{% set uParts = {
'path': '/some/path',
'params': {
'abc': '123'
}
} %}
{% set urlStr = hublify.urlBuild(uParts) %}
gives you like:
"/some/path?abc=123"