From::query()
Converts URL query string to PHP array.
Table of Contents
Description
From::query(?string $from, bool $eval = true, mixed $value = true): array;This method converts URL query string to PHP array so that it can be processed as native array data.
Example
$value = From::query('?foo=bar&baz=qux'); // Returns `['baz' => 'qux', 'foo' => 'bar']`
$value = From::query('?foo&bar=', true, true); // Returns `['bar' => "", 'foo' => true]`
$value = From::query('?foo&bar=', true, null); // Returns `['bar' => "", 'foo' => null]`Conversion
Below are examples of input data along with the conversion results:
| From | To |
|---|---|
'?a=b' | ['a' => 'b'] |
'a=b' | ['a' => 'b'] |
'a[]=b' | ['a' => ['b']] |
'a[]=b&a[]=c' | ['a' => ['b', 'c']] |
'a[1]=b&a[0]=c' | ['a' => ['c', 'b']] |
'a[2]=b&a[1]=c' | ['a' => [1 => 'c', 2 => 'b']] |
'a[b]=c' | ['a' => ['b' => 'c']] |
'a&b=' | ['a' => true, 'b' => ""] |
'a=1&b=1.5&c=.5' | ['a' => 1, 'b' => 1.5, 'c' => 0.5] |
'a=false&b=null&c=true' | ['a' => false, 'b' => null, 'c' => true] |
"" | [] |
null | [] |
From::HTML()
Encodes HTML special characters.
From::JSON()
Decodes JSON string to data.
From::URL()
Encodes URL special characters.
From::_()
Creates a virtual method.
From::__callStatic()
Calls the virtual method that has been created.
From::base64()
Decodes Base64 string.
From::entity()
Converts HTML entities to their corresponding characters.
From::query()
Converts URL query string to PHP array.
From::serial()
Unserializes data.