title: Loop through POST array with PHP
body: <p>I have a form on my website. When I submit it to my PHP script I use <code>var_dump($_POST);</code> to show all the form data that has been submitted. The array follows below.</p>
  
  <p>I'd like to use PHP to run a <em>foreach</em> loop on the following array and group them by the index. </p>
  
  <p><strong>Expected Output:</strong></p>
  
  <pre><code>1 - 111 - 1
  2 - 222 - 2
  3 - 333 - 3
  </code></pre>
  
  <p>So each row would have the relevant <em>name, source and level</em> based on the integer in the array element.</p>
  
  <p>Can someone explain how this is done?</p>
  
  <pre><code>array(11) {
    ["source_name0_id"]=&gt;
    string(1) "1"
    ["source_code0_id"]=&gt;
    string(3) "111"
    ["source_level0_id"]=&gt;
    string(1) "1"
    ["source_name1_id="]=&gt;
    string(1) "2"
    ["source_code1_id="]=&gt;
    string(3) "222"
    ["source_level1_id="]=&gt;
    string(1) "2"
    ["source_name2_id="]=&gt;
    string(1) "3"
    ["source_code2_id="]=&gt;
    string(3) "333"
    ["source_level2_id="]=&gt;
    string(1) "3"
    ["submit"]=&gt;
    string(6) "Submit"
  }
  </code></pre>
  
  <p><strong><em>Thank you!</em></strong></p>