title: if two array key matches then create a new array with their values
body: <p>I have two array. I want to merge then based on their key match. Here is my first array </p>
  
  <pre><code>array(
    (int) 1 =&gt; 'Home',
    (int) 7 =&gt; 'FAQs',
    (int) 16 =&gt; 'Roles',
    (int) 21 =&gt; 'Terms &amp; Condition',
    (int) 24 =&gt; 'Registration',
    (int) 4 =&gt; 'Posts'
  )
  </code></pre>
  
  <p>My second array</p>
  
  <pre><code>array(
     (int) 4 =&gt; array(
              (int) 0 =&gt; 'All Posts',
              (int) 1 =&gt; 'Post Add'
     ),
     (int) 7 =&gt; array(
              (int) 0 =&gt; 'FAQ Add',
              (int) 1 =&gt; 'All FAQs'
     ),
     (int) 16 =&gt; array(
              (int) 0 =&gt; 'Add Role',
              (int) 1 =&gt; 'All Role &amp; Actions'
     ),
     (int) 21 =&gt; array(
                (int) 0 =&gt; 'Add Terms &amp; Condition',
                (int) 1 =&gt; 'Terms &amp; Conditions'
      )
   )
  </code></pre>
  
  <p>What I want to do is to create a new array with their values if key matches.like
  this way. Is this even possible to merge them like this ?</p>
  
  <pre><code> array(
     'Posts' =&gt; array(
              (int) 0 =&gt; 'All Posts',
              (int) 1 =&gt; 'Post Add'
     ),
     'FAQs' =&gt; array(
              (int) 0 =&gt; 'FAQ Add',
              (int) 1 =&gt; 'All FAQs'
     ),
     'Registration' =&gt; array(),
     'Home'=&gt;array(),
     'Roles' =&gt; array(
              (int) 0 =&gt; 'Add Role',
              (int) 1 =&gt; 'All Role &amp; Actions'
     ),
     'Terms &amp; Condition' =&gt; array(
                (int) 0 =&gt; 'Add Terms &amp; Condition',
                (int) 1 =&gt; 'Terms &amp; Conditions'
      )
   )
  </code></pre>