title: Merging many collections in a single one symfony
body: <p>(using Symfony 3.4)</p>
  
  <p>I am trying to create an array collection by merging (getting only the objects) multiple collections. Sounds weird, let me explain.</p>
  
  <p>I take all the users from the db and for each one I want to add in a single array collection all his/her licenses. My code:</p>
  
  <pre><code> $users = $this-&gt;userRepository-&gt;findAllUsers($params);
  
   $users-&gt;forAll(function (User $user) use (&amp;$array) {
       $array = array_merge($array, $user-&gt;getLicenses());
   });
  
   $a = new ArrayCollection($array);
  </code></pre>
  
  <p>How should I resolve this?</p>