title: Flatten Array Result of Symfony Doctrine Array Result
body: <p>With a repository I got an array result (each array is an entity object) like this:</p>
  
  <pre><code>array(
    0 =&gt; object of type entity,
    1 =&gt; another object of type entity,
    2 =&gt; another object of type entity,
  )
  </code></pre>
  
  <p>each object has some properties like id and name, etc.
  But I what I want is flatten the whole array only with the id of each object.</p>
  
  <p>What I want is this (flatten the array only with ID's):</p>
  
  <pre><code>Array
  (
      [0] =&gt; 1
      [1] =&gt; 6
      [2] =&gt; 23
  )
  </code></pre>
  
  <blockquote>
    <p>My solution:</p>
  </blockquote>
  
  <pre><code>$ids = array_map($transform = function($entity) {
      if ($entity instanceof Entity) {
         return $entity-&gt;getId();
      }
   }, $myGreatDbResult);
  </code></pre>
  
  <p>My solution is working but is there a better way to get this result?</p>