Q:

Difference when sending post as an array or as a string in curl

I have an issue with libcurl with php. I was sending post data using a string like that:
    $post="var1=val1&var2=val2";
    curl_setopt($this->ch, CURLOPT_URL, $url);
    curl_setopt($this->ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($this->ch, CURLOPT_POST, 1);
    curl_setopt($this->ch, CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded','Accept-Encoding: gzip'));
    curl_setopt($this->ch,CURLOPT_ENCODING , "gzip");
    curl_setopt($this->ch, CURLOPT_POSTFIELDS, $post);

And it worked perfectly, but I would like to change to use an array instead like that:
    $post=array();
    $post['var1']="val1";
    $post['var2']="val2";

    curl_setopt($this->ch, CURLOPT_URL, $url);
    curl_setopt($this->ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($this->ch, CURLOPT_POST, 1);
    curl_setopt($this->ch, CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded','Accept-Encoding: gzip'));
    curl_setopt($this->ch,CURLOPT_ENCODING , "gzip");
    curl_setopt($this->ch, CURLOPT_POSTFIELDS, $post);

but the server doesn't seems to receive the same thing, is there something I'm missing ?

A:

The note here says:

Note:
  Passing an array to CURLOPT_POSTFIELDS will encode the data as multipart/form-data, while passing a URL-encoded string will encode the data as application/x-www-form-urlencoded.

This may be the reason of the other site doesn't recognize the same way.
As an workaround, you can transform the array to string using $post = http_build_query($post);

