formatRequestArgs.php
Table of Contents
Functions
- formatRequestArgs() : string
- Builds a query string (`?key=value&...`) from an associative array, properly URL-encoding both keys and values.
Functions
formatRequestArgs()
Builds a query string (`?key=value&...`) from an associative array, properly URL-encoding both keys and values.
formatRequestArgs(array<string|int, mixed> $params[, bool $useNow = false ]) : string
Optionally replaces the value of the from key with "now" if $useNow is set to true.
This is useful for formatting request parameters in URLs or APIs.
Parameters
- $params : array<string|int, mixed>
-
The associative array of parameters (e.g.,
['from' => 'yesterday', 'limit' => 10]). - $useNow : bool = false
-
Whether to override the
'from'key with'now'if it exists.
Tags
Return values
string —A URL-compatible query string, starting with ?, or an empty string if $params is empty.