title: how to insert the variables from the loop into an associative array in php
body: <p>I have the following loop:</p>
  
  <pre><code> foreach($_POST as $key =&gt; $value) {
  
             echo "Key:" . $key . " Value: ". $value .   "&lt;br /&gt;";         
  
             }
  </code></pre>
  
  <p>which produce the following result:</p>
  
  <p>Key:1 Value: my value 
  Key:8 Value: my some other value
  Key:9 Value: another value</p>
  
  <p>What I am trying to do is to create an array that would look like this:</p>
  
  <pre><code>$editWhat = array(
                  'field1'            =&gt; $key1,
                  'field2'            =&gt; $key2,
                  'field3'            =&gt; $key3,
                  'field4'        =&gt; $value1,
                  'field5'        =&gt; $value2,
                  'field6'        =&gt; $value3
              ); 
  </code></pre>
  
  <p>Comma should be stripped in the last value pair line in the array, which cause me additional problems. </p>
  
  <p>Any help will be deeply appreciated. </p>
  
  <p>Regards, John</p>