title: Combine two array matching key in PHP
body: <p>I need to Combine two array in PHP，and also have to match the keys</p>
  <p>Here`s my array</p>
  <p>array1 look like</p>
  <pre><code>[
      0 =&gt; &quot;num&quot;,
      1 =&gt; &quot;No&quot;,
      2 =&gt; &quot;Name&quot;,
      3 =&gt; &quot;Phone&quot;,
      4 =&gt; &quot;Price&quot;,
      5 =&gt; &quot;Date&quot;
  ]
  </code></pre>
  <p>array2 look like</p>
  <pre><code>[
      0 =&gt;[
          &quot;No&quot; =&gt; &quot;FR201605832&quot;,
          &quot;Price&quot; =&gt; 199.0,
          &quot;Date&quot; =&gt; &quot;2016-09-01&quot;,
          &quot;num&quot; =&gt; &quot;19&quot;,
          &quot;Name&quot; =&gt; &quot;Tom&quot;,
          &quot;Phone&quot; =&gt; &quot;0900123456&quot;
      ],
      1 =&gt;[
          &quot;No&quot; =&gt; &quot;EC2016010100001&quot;,
          &quot;Price&quot; =&gt; 1680.0,
          &quot;Date&quot; =&gt; &quot;2016-09-01&quot;,
          &quot;num&quot; =&gt; &quot;1680&quot;,
          &quot;Name&quot; =&gt; &quot;Ted&quot;,
          &quot;Phone&quot; =&gt; &quot;0900321654&quot;
      ]
  ]
  </code></pre>
  <p>And Here`s Result What I want</p>
  <pre><code>[
      0 =&gt;[
          &quot;num&quot; =&gt; &quot;19&quot;,
          &quot;No&quot; =&gt; &quot;FR201605832&quot;,
          &quot;Name&quot; =&gt; &quot;Tom&quot;,
          &quot;Phone&quot; =&gt; &quot;0900123456&quot;,
          &quot;Price&quot; =&gt; 199.0,
          &quot;Date&quot; =&gt; &quot;2016-09-01&quot;,
      ],
      1 =&gt; [
          &quot;num&quot; =&gt; &quot;1680&quot;,
          &quot;No&quot; =&gt; &quot;EC2016010100001&quot;,
          &quot;Name&quot; =&gt; &quot;Ted&quot;,
          &quot;Phone&quot; =&gt; &quot;0900321654&quot;,
          &quot;Price&quot; =&gt; 1680.0,
          &quot;Date&quot; =&gt; &quot;2016-09-01&quot;,
      ]
  ]
  </code></pre>
  <p>array1 is User reOrder the input excel heading，I can get the reorder request but don`t know how to combine with the value</p>
  <p>Plz help me to combine two array and export the expect result，Thx</p>
  <hr />
  <p>Here is the next step</p>
  <p>Renam the Result array key by array3</p>
  <p>array3 look like</p>
  <blockquote>
  <p>array:6 [▼</p>
  <p>&quot;num&quot; =&gt; &quot;id&quot;</p>
  <p>&quot;No&quot; =&gt; &quot;ECNo&quot;</p>
  <p>&quot;Name&quot; =&gt; &quot;User&quot;</p>
  <p>&quot;Phone&quot; =&gt; &quot;Mobile&quot;</p>
  <p>&quot;Price&quot; =&gt; &quot;Total&quot;</p>
  <p>&quot;Date&quot; =&gt; &quot;PayDay&quot;</p>
  <p>]</p>
  </blockquote>
  <p>I tried</p>
  <blockquote>
  <p>foreach($exportdata as &amp;$val){</p>
  <p>$val[$values] = $val[$keys];</p>
  <p>unset($val[$value]);</p>
  <p>}</p>
  </blockquote>
  <p>But get error Illegal offset type</p>
  <p>any good idea?</p>