基于公共索引值连接两个多维数组

I need to join two multidimentional arrays on the basis of there common field .please tell me how can i get that ?

i have two multidimentional arrays array1

array1[1][id]=01
array1[1][name]=xyz

and array2

array2[1][id]=01
array2[1][xyz]=anything

i want these two arrays to join on the basis of common index "id"

and need the result like this

array[1][id]=01
array[1][name]=''
array[1][xyz]=''

how can i acheive that please tell me ?

You could do this:

$mergedArray = array();
foreach($array1 as $index1 => $value1){
    foreach($array2 as $index2 => $value2){            
        if($array1[$index1]['id'] == $array2[$index2]['id'])){
            $mergedArray[] = array_merge($array1[$index1], $array2[$index2]);
        }
    }
}