Url::add_url_parameter(): add support for multiple values

This commit is contained in:
Benjamin Renard 2024-11-29 15:38:28 +01:00
parent 48556822a3
commit 7217fe9303
Signed by: bn8
GPG key ID: 3E2E1CE1907115BC

View file

@ -538,12 +538,17 @@ class Url {
*
* @param string $url The URL
* @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)
*
* @return string The completed URL
*/
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)
$url .= '?';
else