title: multidimensional array difference php
body: <p>I have two multidimensional arrays and I want the difference. For eg. I have taken two-dimensional two arrays below</p>
  
  <pre><code>$array1 = Array (
         [a1] =&gt; Array  (
            [a_name] =&gt; aaaaa
            [a_value] =&gt; aaa
       )
  
         [b1] =&gt; Array (
            [b_name] =&gt; bbbbb
            [b_value] =&gt; bbb
     )
         [c1] =&gt; Array (
            [c_name] =&gt; ccccc
            [c_value] =&gt; ccc
     )
  
  )
  
  $array2 = Array (
   [b1] =&gt; Array (
         [b_name]=&gt; zzzzz
       )
  )
  </code></pre>
  
  <p>Now I want the key difference of these two arrays. I have tried array_diff_key() but it doesnot work for multidimensional.  </p>
  
  <pre><code>array_diff_key($array1, $array2)
  </code></pre>
  
  <p>I want the output as following</p>
  
  <pre><code>//output
  $array1 = Array (
     [a1] =&gt; Array  (
        [a_name] =&gt; aaaaa
        [a_value] =&gt; aaa
   )
  
     [b1] =&gt; Array (          
        [b_value] =&gt; bbb
  )
     [c1] =&gt; Array (
        [c_name] =&gt; ccccc
        [c_value] =&gt; ccc
  )
  
  )
  </code></pre>
  
  <p>If you think my question is genuine please accept it and answer. Thank you.</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>Now if the second array is </p>
  
  <pre><code>$array2 = Array( [b1] =&gt; zzzzz)
  </code></pre>
  
  <p>The result should be </p>
  
  <pre><code>$array1 = Array (
     [a1] =&gt; Array  (
        [a_name] =&gt; aaaaa
        [a_value] =&gt; aaa
      )     
  
     [c1] =&gt; Array (
        [c_name] =&gt; ccccc
        [c_value] =&gt; ccc
       )
  
  )
  </code></pre>