You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Nov 26, 2022. It is now read-only.
function League\Uri\query_parse($query, string $separator = '&', int $enc_type = PHP_QUERY_RFC3986): array;
66
+
public static function QueryString::parse($query, string $separator = '&', int $enc_type = PHP_QUERY_RFC3986): array;
68
67
```
69
68
70
69
The returned array is a collection of key/value pairs. Each pair is represented as an array where the first element is the pair key and the second element the pair value. While the pair key is always a string, the pair value can be a string or the `null` value.
71
70
72
-
The `League\Uri\query_parse` parameters are
71
+
The `League\Uri\QueryString::parse` parameters are
73
72
74
73
-`$query` can be the `null` value, any scalar or object which is stringable;
75
74
-`$separator` is a string; by default it is the `&` character;
@@ -82,9 +81,9 @@ Here's a simple example showing how to use all the given parameters:
To convert back the collection of key/value pairs into a valid query string or the `null` value you can use the `League\Uri\query_build` function.
101
+
To convert back the collection of key/value pairs into a valid query string or the `null` value you can use the `QueryString::build` function.
103
102
104
103
```php
105
104
<?php
106
105
107
-
use function League\Uri\query_build;
106
+
use League\Uri\Parser\QueryString;
108
107
109
-
$pairs = query_build([
108
+
$pairs = QueryString::build([
110
109
['module', 'home'],
111
110
['action', 'show'],
112
111
['page', 'toto bar'],
@@ -121,32 +120,32 @@ $pairs = query_build([
121
120
```php
122
121
<?php
123
122
124
-
function League\Uri\query_build(iterable $pairs, string $separator = '&', int $enc_type = PHP_QUERY_RFC3986): ?string;
123
+
public static function QueryString::build(iterable $pairs, string $separator = '&', int $enc_type = PHP_QUERY_RFC3986): ?string;
125
124
```
126
125
127
-
The `League\Uri\query_build` :
126
+
The `QueryString::build` :
128
127
129
-
- accepts any iterable structure containing a collection of key/pair pairs as describe in the returned array of the `League\Uri\query_parse` function.
128
+
- accepts any iterable structure containing a collection of key/pair pairs as describe in the returned array of the QueryString::parse` function.
130
129
131
-
Just like with `League\Uri\query_parse`, you can specify the separator and the encoding algorithm to use.
130
+
Just like with `QueryString::parse`, you can specify the separator and the encoding algorithm to use.
132
131
133
132
- the function returns the `null` value if an empty array or collection is given as input.
134
133
135
134
### Extracting PHP variables
136
135
137
-
`League\Uri\query_parse` and `League\Uri\query_build` preserve the query string pairs content and order. If you want to extract PHP variables from the query string *à la*`parse_str` you can use `League\Uri\query_extract`. The function:
136
+
`QueryString::parse` and `QueryString::build` preserve the query string pairs content and order. If you want to extract PHP variables from the query string *à la*`parse_str` you can use `QueryString::extract`. The public static method:
138
137
139
-
- takes the same parameters as `League\Uri\query_parse`
138
+
- takes the same parameters as `League\Uri\QueryString::parse`
140
139
- does not allow parameters key mangling in the returned array;
0 commit comments