how to pass multiple parameters per url?

1

I want to pass two variables through the same url

I tried this:

$id = '24,54,32,65,34';
$agencia = 'AGIP, ARBA';

"url?id=$id&agencia=$agencia"

Clarification: yes or if it should be by parameters and variables

I am using curl and decode in this way:

function getVencimientos($id){
  $result = fetchVencimientos($id);
  $decode = json_decode(remove_utf8_bom($result), true)['data'];
  var_dump($decode);
  return $decode;
}

function fetchVencimientos($id){
  $agencia = 'AGIP, ARBA';
  $ch = curl_init("url?id=$id&agencia=$agencia");

  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'Content-Type: application/json',
    'Accept: application/json'
  ]);
  curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

  $result = curl_exec($ch);
  curl_close($ch);

  return $result;
}

It returns an html code.

    
asked by Meta Code 07.11.2017 в 21:06
source

2 answers

1

Why do not you try to pass them as JSON?

$id = [24,54,32,65,34];
$agencia = [AGIP, ARBA];

"url?id=".json_encode($id)."&agencia=".json_encode($agencia);

and then on the other side you get the GET parameter and you make a json_decode to recover the arrangement.

    
answered by 07.11.2017 / 21:17
source
0

What you must do is concatenate the variables by removing them from the string as such so that they can obtain their value. Do it this way:

"url?id=".$id."&agencia=".$agencia
    
answered by 07.11.2017 в 21:09