From::query()

Converts URL query string to PHP array.

Table of Contents
  1. Description
  2. Example
  3. Conversion

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:

FromTo
'?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::entity()

Converts HTML entities to their corresponding characters.

From::query()

Converts URL query string to PHP array.