简体   繁体   English

如何回显数组中的项目数?

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

A total newbie question I know. 我知道一个全新的问题。

I'm sing Zend framework, and sending an array from the controller: 我正在唱Zend框架,并从控制器发送一个数组:

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

In the view, I have a foreach loop that is populating a table with the array contents. 在视图中,我有一个foreach循环,用数组内容填充表。

<?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! 谢谢!

试过这个?

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM