title: Merging and combining two arrays in PHP
body: <p>I have two arrays one created from a table in my database and one created from a HTML form (lets call them <strong><code>array_db</code></strong> and <strong><code>array_form</code></strong>).<br> </p>
  
  <p>I want to insert <strong><code>array_db</code></strong> to a table in my <strong>mySQL</strong> database, but before inserting I must merge <strong><code>array_db</code></strong> with <strong><code>array_form</code></strong> and remove duplicates. When there are a duplicates I want the values from <strong><code>array_form</code></strong> to be inserted to <strong><code>array_db</code></strong><br> </p>
  
  <p><strong>NOTE</strong>: <strong><code>array_form</code></strong> are not always the same meaning it could have more or less values than in the below ex.  </p>
  
  <p>What is the best way to do this?</p>
  
  <p><strong>Array_db</strong></p>
  
  <pre><code>Array
  (
      [task_id] =&gt; task_id
  )
  Array
  (
      [user_id] =&gt; user_id
  )
  Array
  (
      [customer_id] =&gt; customer_id
  )
  Array
  (
      [created] =&gt; created
  )
  Array
  (
      [pickup] =&gt; pickup
  )
  Array
  (
      [tire_front] =&gt; tire_front
  )
  Array
  (
      [tire_back] =&gt; tire_back
  )
  Array
  (
      [tire_reg] =&gt; tire_reg
  )
  Array
  (
      [tire_indl] =&gt; tire_indl
  )
  Array
  (
      [tube_front] =&gt; tube_front
  )
  Array
  (
      [tube_back] =&gt; tube_back
  )
  Array
  (
      [hub_front] =&gt; hub_front
  )
  Array
  (
      [hub_back] =&gt; hub_back
  )
  Array
  (
      [hub_adjust] =&gt; hub_adjust
  )
  Array
  (
      [rim_front] =&gt; rim_front
  )
  Array
  (
      [rim_back] =&gt; rim_back
  )
  Array
  (
      [rim_adjust] =&gt; rim_adjust
  )
  Array
  (
      [spoke_missing_front] =&gt; spoke_missing_front
  )
  Array
  (
      [spoke_missing_back] =&gt; spoke_missing_back
  )
  Array
  (
      [spoke_comp_front] =&gt; spoke_comp_front
  )
  Array
  (
      [spoke_comp_back] =&gt; spoke_comp_back
  )
  Array
  (
      [break_adjust_front] =&gt; break_adjust_front
  )
  Array
  (
      [break_adjust_back] =&gt; break_adjust_back
  )
  Array
  (
      [break_cable_front] =&gt; break_cable_front
  )
  Array
  (
      [break_cable_back] =&gt; break_cable_back
  )
  Array
  (
      [break_pad_front] =&gt; break_pad_front
  )
  Array
  (
      [break_pad_back] =&gt; break_pad_back
  )
  Array
  (
      [gear_adj_front] =&gt; gear_adj_front
  )
  Array
  (
      [gear_adj_back] =&gt; gear_adj_back
  )
  Array
  (
      [gear_cable_front] =&gt; gear_cable_front
  )
  Array
  (
      [gear_cable_back] =&gt; gear_cable_back
  )
  Array
  (
      [gear_shift_front] =&gt; gear_shift_front
  )
  Array
  (
      [gear_shift_back] =&gt; gear_shift_back
  )
  Array
  (
      [bicy_chain] =&gt; bicy_chain
  )
  Array
  (
      [cog_wheel] =&gt; cog_wheel
  )
  Array
  (
      [cassette] =&gt; cassette
  )
  Array
  (
      [chainwheel] =&gt; chainwheel
  )
  Array
  (
      [crankset] =&gt; crankset
  )
  Array
  (
      [crank] =&gt; crank
  )
  Array
  (
      [fp_service] =&gt; fp_service
  )
  Array
  (
      [status] =&gt; status
  )
  Array
  (
      [service_1] =&gt; service_1
  )
  Array
  (
      [service_2] =&gt; service_2
  )
  Array
  (
      [service_3] =&gt; service_3
  )
  Array
  (
      [service_4] =&gt; service_4
  )
  Array
  (
      [price_approx] =&gt; price_approx
  )
  Array
  (
      [price_max] =&gt; price_max
  )
  </code></pre>
  
  <p><strong>Array_form</strong></p>
  
  <pre><code>(
  [tire_back] =&gt; tire_back
  [tube_back] =&gt; tube_back
  [gear_shift_front] =&gt; gear_shift_front
  [user_id] =&gt; 0
  [customer_id] =&gt; 6
  )
  </code></pre>