2

As recommended in this question I changed my script to use http_build_query to create a well-formed querystring. This works fine except for a small part.

The interface awaits images, there can be several of them, with the same parameter name for all of them, like this:

&images=$a&images=$b&images=$c

When using http_build_query and passing an array the querystring in the end looks like this:

&images[0]=$a&images[1]=$b&images[2]=$c

This will fail with the interface and so I need to get rid of the indexes at all. I have seen this solution but I´d like to stick to http_build_query.

Any ideas how to do this?

flomei
  • 860
  • 1
  • 11
  • 36
  • I think the problem is with your "interface". It's a valid query string. Except for the fact that square brackets should be encoded to "%5B" for "[" and "%5D" for "]". – wazelin Jun 24 '16 at 13:16
  • Have you seen if the query parses back to 3 images if you name them all the same key without arraying them? – Rasclatt Jun 24 '16 at 13:18
  • @Wazelin It's not a "problem with the interface" either, it's a mismatch of expectations. Yes, `[...]` is *valid*, but if that's not the *expected* way multiple values are defined, that doesn't help. – deceze Jun 24 '16 at 13:18
  • But it is the correct one. – wazelin Jun 24 '16 at 13:19
  • @Rasclatt PHP won't parse them back to an array, no. Other languages/programs do. – deceze Jun 24 '16 at 13:19
  • @Wazelin Please point to some official document specifying ***URL syntax*** that says `[...]` is "the correct one". – deceze Jun 24 '16 at 13:19
  • @deceze that's good to know! I did not know that. – Rasclatt Jun 24 '16 at 13:20
  • 3
    Anyway you can strip the indexes down like [this](http://stackoverflow.com/questions/8170306/http-build-query-with-same-name-parameters). – wazelin Jun 24 '16 at 13:22
  • Thank you very much, that helped me! – flomei Jun 24 '16 at 13:38

0 Answers0