title: PHP square brackets for arrays
body: <p>I am trying to send multiple files with the <a href="https://www.phaxio.com/docs/api/send/sendFax/" rel="nofollow">Phaxio API</a>, and I can't get past their <code>[]</code> notation.</p>
  
  <p>In order to pass multiple files, the parameters necessary that DO work are:</p>
  
  <p>This works:</p>
  
  <pre><code>"filename[]"=&gt;"@file1.pdf", "@file2.pdf", "@file3.pdf"
  </code></pre>
  
  <p>How would I go about generating the right side (the values) in an actual array such as $files = array("file1.pdf", "$file2.pdf", "file3.pdf");</p>
  
  <p>The syntax is just not working out for me so far, I've tried:</p>
  
  <p>These do not work:</p>
  
  <pre><code>"filename[]"=&gt;array("@file1.pdf", "@file2.pdf", "@file3.pdf")
  </code></pre>
  
  <p>OR</p>
  
  <pre><code>"filename"=&gt;array("@file1.pdf", "@file2.pdf", "@file3.pdf")
  </code></pre>
  
  <p>OR</p>
  
  <pre><code>"filename"=&gt;"@file1.pdf, @file2.pdf, @file3.pdf"
  </code></pre>
  
  <p>I am using PHP 5.3.10</p>
  
  <p>The notation that does work generates something along these lines:</p>
  
  <pre><code>[filename[]]=&gt;"@file1.pdf",
  [0]=&gt;"@file2.pdf",
  [1]=&gt;"@file3.pdf"
  </code></pre>
  
  <p><hr>
  @Halcyon :  </p>
  
  <p>I tried the following:</p>
  
  <pre><code>$files =array("filename" =&gt; array("@uploads/invite_template.pdf", "@uploads/2.pdf"));
  
  $data = array(
              "to"=&gt;"$faxToNumber", 
              "filename[]"=&gt;$files
               );
  </code></pre>
  
  <p>I can't just add the array to it as it's an associative array (ex:)</p>
  
  <pre><code>$data = array(
              "to"=&gt;"$faxToNumber", 
               $files
               );
  </code></pre>
  
  <p>I can just append to the data array and that'll make it work but.. how do I make it work with the way you are encoding it?</p>
  
  <p>This works properly so far:</p>
  
  <pre><code>$data += array("filename[0]"=&gt;"@uploads/1.pdf");
  $data += array("filename[1]"=&gt;"@uploads/2.pdf");
  </code></pre>