0

when submitting a form via POST, one common way to send arrays is to give names as follows:

<input name="foo[]" value="" /> <input name="foo[]" value="" /> <input name="foo[]" value="" /> 

However, when sending this via method GET, the browser urlencodes the [], which results in a url like ?foo%5B%5D=bar instead of ?foo[]=bar.

Can this be prevented?

9
  • do you really need $_GET? I mean $_POST is way better, in terms of security, cleansyness etc.. Commented Sep 11, 2018 at 15:34
  • if you have access to a backend language (e.g. php) you can use implode('|', $foo) and it will output ?foo=val1|val2|val3 Commented Sep 11, 2018 at 15:35
  • The form in question sends filter-params for a search. The resulting URL should be shareable. Also, I am using Symfony and try to only use what they already implemented (i.e don't mess with the $_GET-var myself) Commented Sep 11, 2018 at 15:35
  • There's nothing wrong with that URL. It is shareable as is. Commented Sep 11, 2018 at 15:36
  • 1
    wait - if it's a search - why is foo an array? surely you're searching by unique params rather than multiple ones that fits one param? Commented Sep 11, 2018 at 15:37

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.