More than one value in the same GET parameter

0

Is it possible to assign more than one value to the same GET parameter via http, as if I had passed an array in this parameter?

For example: link

Edit1: The application that will receive the request is developed in Laravel, if that influences.

    
asked by anonymous 28.06.2018 / 14:39

2 answers

3

Yes, it is possible to pass in this way, you can use explode() then to get each value individually.

$campos = explode(",", $_GET["campos"]);

You can also pass as an array

// ?campos[]=nome&campos[]=data&campos[]=endereco
$campos = $_GET["campos"]; // já vai ser um array
    
28.06.2018 / 14:49
2

You can, of course, put [] after the parameter name, so it will automatically mount array , the parameters would look like this:

  

• fields [] = name & fields [] = date & fields [] = address

When doing a var_dump($_GET) , the return will be:

  

array (1) {["fields"] = > array (3) {[0] = > string (4) "name" [1] = >   string (4) "data" [2] = > string (9) "address"}}

    
28.06.2018 / 14:51