title: multipart form encoding a string with PHP
body: <p>I am writing PHP code to send XML string data to a site using HTTP post with the encType: multipart/form-data encoding.  I am thinking of using PHP's http_post_data function. Before sending the data, I believe I need to encode it, but I cannot see a PHP function to do this for me, nor do I know how to write such a function myself.</p>
  
  <p>This is what I have so far (but http_request_body_encode() is certainly not the correct function):</p>
  
  <pre><code>$options = array('headers' =&gt; array('Content-Type' =&gt; 'multipart/form-data'));
  $fields = array('operation' =&gt;'doMDUpload', 'login_id' =&gt; $doi_username, 'login_passwd' =&gt; $doi_password, 
    'area' =&gt; ($debug ? "test" : "live"), 'fname' =&gt; $writer-&gt;outputMemory());
  $info = array();
  $response = http_post_data($crossref_deposit_url, http_request_body_encode($fields, array()), $options, $info);
  </code></pre>
  
  <p><code>$writer-&gt;outputMemory</code> is an XML string containing bibliometric data.</p>