M
M
magary42017-01-27 13:08:13
symfony
magary4, 2017-01-27 13:08:13

Generate route, parameter as array of values? as?

doing so

$this->generateUrl("some-route", [ "filter" => [123,456] ] )

get
/my-route?filter%5B0%5D=123&filter%5B1%5D=456
т.е ?filter[0]=123&filter[1]=456

and i want filter[]=123&filter[]=456 (no array key)
how ?
thanks in advance

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Egor Gruzdev, 2017-02-07
@egor_gruzdev

An example from the documentation for the http_build_query function:

$parameters = ['files' => [1,2,3,4,5,6,7,8,9,10]];
echo $query = http_build_query($parameters);
echo $query = preg_replace('/%5B[0-9]+%5D/simU', '%5B%5D', $query);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question