How do I echo the number of items in an array?

Posted by Joel on Stack Overflow See other posts from Stack Overflow or by Joel
Published on 2010-06-06T06:40:46Z Indexed on 2010/06/06 6:42 UTC
Read the original article Hit count: 312

Filed under:
|
|

A total newbie question I know.

I'm sing Zend framework, and sending an array from the controller:

$this->view->googleArray = $viewFeedArray;

In the view, I have a foreach loop that is populating a table with the array contents.

<?php 
foreach($this->googleArray as $row) { ?>
  <tr>          
    <td><?php echo $row['when']; ?></td>
    ...
    ...
  </tr>
<?php
}
?>

It all works fine. At the top of the table, I want to list the number of items in the array.

Something like (which doesn't work):

 <?php echo $this->googleArray->totalResults; ?> event(s) found

How would I do that?

Thanks!

© Stack Overflow or respective owner

Related posts about php

Related posts about oop