在php中合并多个数组

Here is a sample array values that is returning:

Here is the first array:

Array 1:

     0 => 
      name => Test name value
      desrciption => Test description value
      category => Test category value
      code_1 => IGEF001
      code_2 => IGGF001

     1 => 
      name => Test name value
      desrciption => Test description value
      category => Test category value
      code_1 => IGEF003
      code_2 => IGGF003

     2 => 
       name => Test name value
       desrciption => Test description value
       category => Test category value
       code_1 => IGEF004
       code_2 => IGGF004

Here is the second array:

Array 2:

 0 => 
    return_code => IGEF003

 1 => 
   return_code => IGGF003

 2 => 
   return_code => IGGF004

 3 => 
   return_code => IGEF004

 4 => 
   return_code => IGGF001

 5 => 
   return_code => IGEF001

Here is what I'm trying to accomplish:

 0 => 
   name => Test name value
   desrciption => Test description value
   category => Test category value
   code_1 => IGEF001
   code_2 => IGGF001
   select_code_1 => IGEF001 <-- Value coming from the second array
   select_code_2 => IGGF001 <-- Value coming from the second array


 1 => 
  name => Test name value
  desrciption => Test description value
  category => Test category value
  code_1 => IGEF003
  code_2 => IGGF003
  select_code_1 => IGEF003 <-- Value coming from the second array
  select_code_2 => IGGF003 <-- Value coming from the second array

 2 => 
  name => Test name value
  desrciption => Test description value
  category => Test category value
  code_1 => IGEF004
  code_2 => IGGF004
  select_code_1 => IGEF004 <-- Value coming from the second array
  select_code_2 => IGGF004 <-- Value coming from the second array

I hope this is enough information, let me know if you need any more.

Well, if I understood your question correctly, you want to find matching entries in the second array and add them to the first array. For the purpose of keeping this example simple, I assume that matching entries always exist. If that's not the case, you need to add an if with array_key_exists() or something.

$result = array();
foreach ($array1 as $key => $value) {
   $result = $value;
   $result['select_code'] = $array2[$key]['return_code'];
}

What I could not figure out is where the second "select_code" entry in the result should be found. The only way to map entries in the first with entries in the second array is the key, as far as I can tell. If you provide more insight on the nature of your data, I will edit my answer.

Never mind I found a solution. What I did was I called the query inside a for loop for the 1st array and link the values. So instead of having two separate arrays I decided to create a single array and that did the trick.

Thank you for your help..