Guzzle 6: remove PHP brackets from the names of multiple values fields

In Guzzle 3 the way to deal with this problem was to use the method setAggregator() with a DuplicateAggregator or CommaAggregator.

With Guzzle 6, you have to manually build the request body with a special function provided by Guzzle which doesn't add PHP brackets:

// parameters to send
$params = [...]
 
$query_string = \GuzzleHttp\Psr7\build_query($params, PHP_QUERY_RFC1738);
 
$options = [];
$options['body'] = $query_string ;
$options['headers'] = ['Content-Type' => 'application/x-www-form-urlencoded'];
 
// send request
$response = $client->request('POST', $url, $options);

I added this (also from Guzzle) to remove empty parameters:

// remove null values
foreach ($params as $k => $v) {
    if ($v === null) {
        unset($params[$k]);
    }
}

Feedback