Url::add_url_parameter(): add support for multiple values
This commit is contained in:
parent
48556822a3
commit
7217fe9303
1 changed files with 6 additions and 1 deletions
|
@ -538,12 +538,17 @@ class Url {
|
||||||
*
|
*
|
||||||
* @param string $url The URL
|
* @param string $url The URL
|
||||||
* @param string $parameter The parameter name
|
* @param string $parameter The parameter name
|
||||||
* @param string|null $value The parameter value (optional)
|
* @param string|array<string>|null $value The parameter value (optional)
|
||||||
* @param boolean $encode Set if parameter value must be URL encoded (optional, default: true)
|
* @param boolean $encode Set if parameter value must be URL encoded (optional, default: true)
|
||||||
*
|
*
|
||||||
* @return string The completed URL
|
* @return string The completed URL
|
||||||
*/
|
*/
|
||||||
public static function add_url_parameter($url, $parameter, $value=null, $encode=true) {
|
public static function add_url_parameter($url, $parameter, $value=null, $encode=true) {
|
||||||
|
if (is_array($value)) {
|
||||||
|
foreach($value as $v)
|
||||||
|
$url = self :: add_url_parameter($url, $parameter."[]", $v);
|
||||||
|
return $url;
|
||||||
|
}
|
||||||
if (strpos($url, '?') === false)
|
if (strpos($url, '?') === false)
|
||||||
$url .= '?';
|
$url .= '?';
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in a new issue