title: (PHP) $_POST + cURL + multi array
body: <p>I try to send a multi array via <code>cURL</code> but I can't find a nice way to do it.</p>
  
  <p>My code example:</p>
  
  <pre><code>$data = array( 'a' =&gt; 'testa', 'b' =&gt; 'testb', 'c[d]' =&gt; 'test1', 'c[e]' =&gt; 'test2' );
  
  curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
  </code></pre>
  
  <p>This will work and give the result I want on the <code>curl_init()</code> site:</p>
  
  <p><code>print_r( $_POST )</code> :</p>
  
  <pre><code>Array (
  
      [a] =&gt; testa
      [b] =&gt; testb
      [c] =&gt; Array (
  
              [d] =&gt; test1
              [e] =&gt; test2
      )
  )
  </code></pre>
  
  <p>I'd like to add the c array dynamically like:</p>
  
  <pre><code>$c['d'] = 'test1';
  $c['e'] = 'test2';
  </code></pre>
  
  <p>But if I try to add an array with <code>array_push</code> or <code>[]</code> I always get and (string)Array in the Array without data.</p>
  
  <p>Can anyone help me to do it?</p>
  
  <p>The whole code for faster testing:</p>
  
  <pre><code>$url = 'url_to_test.php';
  $data = array( 'a' =&gt; 'testa', 'b' =&gt; 'testb', 'c[d]' =&gt; 'test1', 'c[e]' =&gt; 'test2' );
  $ch = curl_init($url);
  curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 );
  curl_setopt($ch, CURLOPT_POST, 1);
  curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
  $buffer = curl_exec ($ch);
  curl_close ($ch);
  
  echo $buffer;
  </code></pre>
  
  <p>The test.php</p>
  
  <pre><code>print_r($_POST);
  </code></pre>
  
  <p>Thanks for any help!</p>
  
  <p>cheers</p>