Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Uri.php

function Uri::withQueryValues

Creates a new URI with multiple specific query string values.

It has the same behavior as withQueryValue() but for an associative array of key => value.

Parameters

UriInterface $uri URI to use as a base.:

(string|null)[] $keyValueArray Associative array of key and values:

File

vendor/guzzlehttp/psr7/src/Uri.php, line 342

Class

Uri
PSR-7 URI implementation.

Namespace

GuzzleHttp\Psr7

Code

public static function withQueryValues(UriInterface $uri, array $keyValueArray) : UriInterface {
    $result = self::getFilteredQueryString($uri, array_keys($keyValueArray));
    foreach ($keyValueArray as $key => $value) {
        $result[] = self::generateQueryString((string) $key, $value !== null ? (string) $value : null);
    }
    return $uri->withQuery(implode('&', $result));
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal