2010-06-06 37 views
2

我知道一个总的新手问题。如何回显数组中的项目数量?

我唱Zend的框架,并从控制器发送的数组:

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

在视图中,我有一个foreach循环被填充表与阵列的内容。

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

这一切正常。在表格的顶部,我想列出数组中的项目数量。

喜欢的东西(不工作):

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

我会怎么做呢?

谢谢!

回答

8

试过吗?

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

甜!工作很棒!我一直在为此工作一个多小时。谢谢! – Joel 2010-06-06 06:50:08

+0

是的 - 我正在倒计时的分钟,直到我可以接受答案... – Joel 2010-06-06 06:55:13

+0

@Joel:这里是一个可用的数组函数的列表:http://php.net/manual/en/ref.array.php可以来便利。你应该总是阅读文档。 – 2010-06-06 09:34:25

相关问题