title: Store multiple post values in array using set of input fields and echo it as list
body: <p>So as title says, I'm trying to make a list of post data using 1 rowset of values.</p>
  
  <p>Basically I have 13 input fields containing codenr,artnr,productname,count,price,etc.
  so when data would be posted they will be stored in array(multi dimensional?).Then echoed out and emailed to me. </p>
  
  <p>I have tried to use <code>foreach()</code> function to go through posted values, but I'm clueless how I would populate the array and make list of it?
  Any suggestions would be appreciated.</p>
  
  <h2>test.php</h2>
  
  <pre><code>&lt;?php
  class postgrab{
   public $posts = array(),$result = array();  
   public function posteddata($posts){
    foreach($posts as $datavalue){
    $result[] = $datavalue;
    }
    return $result;
  }
  }
  ?&gt;
  
  &lt;html&gt;
  &lt;body&gt;
    &lt;form action="" method="post"&gt;
    &lt;input type="text" name="codenr"&gt;
    &lt;input type="text" name="artnr"&gt;
    &lt;input type="text" name="productname"&gt;
    &lt;input type="text" name="price"&gt;
    &lt;input type="submit" name="add item"&gt;
  &lt;/form&gt;
  &lt;?php
  $list = new postgrab();
  $list-&gt;posteddata($posts = array($_POST['codenr'],$_POST['artnr'],$_POST['productname'],$_POST['price']));
  print_r($list-&gt;result);
  ?&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>This gives me just " array() "
  Would love to know how i could get list something like this.</p>
  
  <pre><code>1)codenr = 123 artnr = 254 productname=apple count = 10 price = 0.50&lt;br&gt;
  2)codenr = 321 artnr = 256 productname=pear count = 15 price = 0.69
  </code></pre>
  
  <h2>update</h2>
  
  <p>Changed code like this</p>
  
  <pre><code>class postgrab{
  
       public $posts = array(),$result = array();  
  
          public function posteddata($posts){
              foreach($posts as $datavalue =&gt; $value){
               $this-&gt;result[] = array($datavalue =&gt; $value);
              }
          return $this-&gt;result;
          }
      }
  
      $list = new postgrab();
      $list-&gt;posteddata($posts = array($_POST['codenr'],$_POST['artnr'],$_POST['productname'],$_POST['price']));
      foreach($list-&gt;result as $items){
          foreach($items as $item =&gt; $itemvalue){
          echo $item.'='.$itemvalue;
          }
      }
      ?&gt;
  </code></pre>
  
  <p>now its shows me results like so.</p>
  
  <pre><code>   0 = tes1 1 = tes2 2 = tes3 3 = tes4
  </code></pre>
  
  <p>but still does not populate array just replace array values with new ones.
  Any suggestions?</p>