title: Laravel : How create new array from two arrays with deferent length
body: <p>I have two arrays with different lengths in a controller like the following.</p>
  <pre><code>$absences = Absence::query()
      -&gt;select('name')
      -&gt;selectRaw('count(name) as counts')
      -&gt;whereBetween('date', [$req-&gt;from, $req-&gt;to])
      -&gt;where('stage', $req-&gt;stage)
      -&gt;where('group', $req-&gt;group)
      -&gt;where('subject', $req-&gt;subject)
      -&gt;where('vacs', 'No')
      -&gt;groupBy('name')
      -&gt;get();
  
  $vacs = Absence::query()
      -&gt;select('name')
      -&gt;selectRaw('count(name) as counts')
      -&gt;whereBetween('date', [$req-&gt;from, $req-&gt;to])
      -&gt;where('stage', $req-&gt;stage)
      -&gt;where('group', $req-&gt;group)
      -&gt;where('subject', $req-&gt;subject)
      -&gt;where('vacs', 'yes')
      -&gt;groupBy('name')
      -&gt;get();
  </code></pre>
  <p>Depending on this I will get two arrays, the outputs will be something like the following.</p>
  <p><strong>Absence output</strong></p>
  <pre><code>[
    {
      &quot;name&quot;: &quot;Sam&quot;,
      &quot;counts&quot;: 2
    },
    {
      &quot;name&quot;: &quot;Tom&quot;,
      &quot;counts&quot;: 1
    }
  ]
  </code></pre>
  <p><strong>Vacs output</strong></p>
  <pre><code>[
    {
      &quot;name&quot;: &quot;Sam&quot;,
      &quot;counts&quot;: 1
    }
  ]
  </code></pre>
  <p>Now I want to create a new array with this output:</p>
  <pre><code>[
    {
      &quot;name&quot;: &quot;Sam&quot;,
      &quot;abs_counts&quot;: 2,
      &quot;vac_counts&quot;: 1,
    },
    {
      &quot;name&quot;: &quot;Tom&quot;,
      &quot;abs_counts&quot;: 1,
      &quot;vac_counts&quot;: 0,
    }
  ]
  </code></pre>