title: How to count objects in array?
body: <p>So I've been working with symfony for a while and I'm trying to understand how it works. So, I tried to count how many tasks do I have in my <em>tasks</em> array.</p>
  
  <p>This is my homeController.php class:</p>
  
  <pre><code> public function succesfulLogin(Request $request)
  {
  
      $repository = $this-&gt;getDoctrine()-&gt;getRepository('AppBundle:Task');
      $tasks = $repository-&gt;findByAuthor($this-&gt;getUser()-&gt;getUsername());
      $points = 0;
  
      foreach($tasks as $task){
          $points++;
      }
  
      return $this-&gt;render(
          'userpage.html.twig',array('username' =&gt; $username = $this-&gt;getUser()-&gt;getUsername(), 'tasks' =&gt; $tasks, 'points' =&gt; $points ));
      $user-&gt;getTasks();
     //as I understant I return '$tasks' array to twig with all my tasks
     //so before returning '$tasks' array it should have 21 object in it?(not 13)
     //am I wrong?
  }
  </code></pre>
  
  <p>So I pass 'points' to twig and twig prints out number <strong>13</strong>, but when I try to print out all <em>tasks</em> in twig, it says that I have 21 task.
  There is some twig code:</p>
  
  <pre><code>{% for task in tasks %}//this foreach loop prints out 21 task
          &lt;tr&gt;
              &lt;td id&gt;{{ task.Id }}&lt;/td&gt;
              &lt;td&gt;{{ task.Status }}&lt;/td&gt;
              &lt;td&gt;{{ task.Name }}&lt;/td&gt;
              &lt;td&gt;{{ task.Description }}&lt;/td&gt;
              &lt;td&gt;{{ task.Category }}&lt;/td&gt;
              &lt;td&gt;{{ task.Author }}&lt;/td&gt;
              &lt;td&gt;{{ task.CreationDate|date("m/d/Y") }}&lt;/td&gt;
              &lt;td&gt;&lt;a id="myLink" href="/edit/{{ task.ID }}" &gt; Edit &lt;/a&gt;&lt;/td&gt;
              &lt;td&gt;&lt;a id="myLink" href="/delete/{{ task.ID }}" &gt;Delete&lt;/a&gt;&lt;/td&gt;
              &lt;?php echo 2+2; ?&gt;            &lt;/tr&gt;
      {% endfor %}
  </code></pre>