diff --git a/components/http_foundation.rst b/components/http_foundation.rst index a9131112d1d..594ce070b4e 100644 --- a/components/http_foundation.rst +++ b/components/http_foundation.rst @@ -162,16 +162,16 @@ exist:: $request->query->get('bar', 'baz'); // returns 'baz' -When PHP imports the request query, it handles request parameters like -``foo[bar]=baz`` in a special way as it creates an array. The ``get()`` method -doesn't support returning arrays, so you need to use the following code:: +To access request parameters like ``foo[bar]=baz``, you can use the following code:: // the query string is '?foo[bar]=baz' - // don't use $request->query->get('foo'); use the following instead: - $request->query->all('foo'); + $request->query->get('foo'); // returns ['bar' => 'baz'] + $request->query->get('foo')['bar']; + // returns "baz" + // if the requested parameter does not exist, an empty array is returned: $request->query->all('qux'); // returns []