If I have:
$_POST['test']
then can I use:
$request->getParameter('test');
But how can I use this if I have $_POST['test']['two']?
Now only one way do to it:
$arr = $request->getParameter('test');
$two = $arr['two'];
Edited:
In PHP 5.4 you can do it $request->getParameter('test')['two'];
2nd Edition :
In Symfony 6 and 7 the correct answer is
$request->request->all('test')['two'];
When you ask for array in GET call:
$request->query->all('test')['two'];
As of Symfony 2, there's even a prettier solution to get array values with the Symfony Request:
$request->get("test[two]", null, true)
The third parameter of get(), $deep, is false by default and decides whether you can access array keys.
See the documentation of the ParameterBag:
boolean $deep: If true, a path like foo[bar] will find deeper items
http://api.symfony.com/2.0/Symfony/Component/HttpFoundation/ParameterBag.html#method_get
As antongorodezkiz pointed out in his comment to this answer, please note that this "is deprecated since version 2.8 and will be removed in 3.0."
ParameterBag::get() is deprecated since version 2.8 and will be removed in 3.0." github.com/symfony/symfony/blob/2.8/CHANGELOG-2.8.mdthere is a easy way to get the whole request
$var = $request->request->all()
$var will be an array. http://symfony.com/doc/current/components/http_foundation/introduction.html#accessing-request-data