cURL using a string to post multiple values

curl, php

Solution

Can we include your answer on the above code?

<?php

$ch = curl_init(); //http post to another server

curl_setopt($ch, CURLOPT_URL,"http://www.example.com");

curl_setopt($ch, CURLOPT_POST, 1);

  $username = 'user1';
  $password = 'strongpassword';

  $values = array(
    'username' => $username,
    'password' => $password,
    'multiple' => array(
        'value1',
        'value2',
        'value3',
    )
  );

$params = http_build_query($values);

curl_setopt($ch, CURLOPT_POSTFIELDS,$params); 

// receive server response

curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$server_output = curl_exec ($ch);

print_r($server_output);

curl_close ($ch);

For example

Problem

Is there a way to post a string with multiple values following the code below? please consider the third postfield $multiple to output more than one value Thanks in advance ``` <?php $ch = curl_init(); //http post to another server curl_setopt($ch, CURLOPT_URL,"http://www.example.com"); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS,"username=$username&password=$password&multiple=$ "); // receive server response curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $server_output = curl_exec ($ch); print_r($server_output); curl_close ($ch); ```

Original source