title: Merge two php arrays on base on specific key and value
body: <p>I have two arrays:</p>
  <pre><code>    Array
      (
  [0] =&gt; Array
      (
          [semCategoryDocID] =&gt; 5
          [semCategoryID] =&gt; 8
          [docTypeID] =&gt; 1
          [semCategoryDocRequired] =&gt; 0
          [semCategoryDocAtom] =&gt; 0
          [docTypeName] =&gt; ID
      )
  
  [1] =&gt; Array
      (
          [semCategoryDocID] =&gt; 8
          [semCategoryID] =&gt; 8
          [docTypeID] =&gt; 2
          [semCategoryDocRequired] =&gt; 1
          [semCategoryDocAtom] =&gt; 1
          [docTypeName] =&gt; Passport
      )
  
  [2] =&gt; Array
      (
          [semCategoryDocID] =&gt; 9
          [semCategoryID] =&gt; 8
          [docTypeID] =&gt; 5
          [semCategoryDocRequired] =&gt; 1
          [semCategoryDocAtom] =&gt; 0
          [docTypeName] =&gt; Request
      )
  
  [3] =&gt; Array
      (
          [semCategoryDocID] =&gt; 14
          [semCategoryID] =&gt; 8
          [docTypeID] =&gt; 8
          [semCategoryDocRequired] =&gt; 0
          [semCategoryDocAtom] =&gt; 1
          [docTypeName] =&gt; Other
      )
  
  [4] =&gt; Array
      (
          [semCategoryDocID] =&gt; 15
          [semCategoryID] =&gt; 8
          [docTypeID] =&gt; 4
          [semCategoryDocRequired] =&gt; 0
          [semCategoryDocAtom] =&gt; 1
          [docTypeName] =&gt; Doc GDPR
      )
  
  )
  
  
  Array
  (
      [0] =&gt; Array
          (
          [applicationDocID] =&gt; 54
          [applicationID] =&gt; 8530
          [semCategoryDocID] =&gt; 5
          [applicationDocName] =&gt; 8530_2014-09-09-1739319PAR1.pdf
          [applicationDocDate] =&gt; 2020-07-14 15:00:07
      )
  
  [1] =&gt; Array
      (
          [applicationDocID] =&gt; 55
          [applicationID] =&gt; 8530
          [semCategoryDocID] =&gt; 9
          [applicationDocName] =&gt; 8530_2014-09-09-17465716PAR.pdf
          [applicationDocDate] =&gt; 2020-07-14 15:00:07
      )
  
  )
  </code></pre>
  <p>I am trying to create new array on from those 2, which will include all elements from both arrays
  on base on the key semCategoryDocID</p>
  <p>So the new array will have 5 elements, but 2 of them will have extra fields, which comes from array 2.</p>
  <p>I tried the following code:</p>
  <pre><code>foreach($possible_documents_list as $key =&gt; $d){
      $possible_documents_list[$key]['applicationDocID'] = '';
      $possible_documents_list[$key]['applicationID'] = '';
      $possible_documents_list[$key]['applicationDocName'] = '';
      $possible_documents_list[$key]['applicationDocDate'] = '';                               
  }            
  
  foreach($uploaded_additional_documents as $key){
      if(in_array($key['semCategoryDocID'], array_column($possible_documents_list, 'semCategoryDocID'))) {
          $possible_documents_list['applicationDocID'] = '';
          $possible_documents_list['applicationID'] = '';
          $possible_documents_list['applicationDocName'] = '';
          $possible_documents_list['applicationDocDate'] = '';       
      } 
  }
  </code></pre>
  <p>But without success, so any help will be deeply appreciated.</p>