title: Count json objects in array
body: <p>Struggling to get the count of all objects in my array to spit out number in json. Can anyone help?</p>
  
  <pre><code>try {
      $conn-&gt;setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);   
  
      $stmt = $conn-&gt;prepare('SELECT * FROM date_blocks WHERE user_id = :user_id');
      $stmt-&gt;execute(array('user_id' =&gt; $user_id));
  
      while($row = $stmt-&gt;fetch()) {
          $startTime = strtotime($row['start_date']);
          $endTime = strtotime($row['end_date']);
  
  
          for ($i = $startTime; $i &lt;= $endTime; $i = $i + 86400) {
              $getDate = date('Y-m-d H:i:s', $i); 
              $return[]=array('date'=&gt;$getDate,
                      'id'=&gt;$row['id']);
          }
  
  
      }
  } catch(PDOException $e) {
      echo 'ERROR: ' . $e-&gt;getMessage();
  }
  header('Content-type: application/json');
  echo json_encode($return);
  </code></pre>