Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/253.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 有没有办法不使用foreach语句就从Zend集合中获取第一项_Php_Zend Framework_Collections - Fatal编程技术网

Php 有没有办法不使用foreach语句就从Zend集合中获取第一项

Php 有没有办法不使用foreach语句就从Zend集合中获取第一项,php,zend-framework,collections,Php,Zend Framework,Collections,当从fieldset类中获取表单项时,我使用下面的代码,它可以工作。问题是:是否有可能在没有foreach语句的情况下获得$item var?类似这样的东西就是我想要的:$collection->{1}->get('event\u timeblock\u label) $collection = $this->form->get('timeblocks'); foreach($collection as $item) {} echo $this->formLabel($ite

当从fieldset类中获取表单项时,我使用下面的代码,它可以工作。问题是:是否有可能在没有foreach语句的情况下获得$item var?类似这样的东西就是我想要的:$collection->{1}->get('event\u timeblock\u label)

$collection = $this->form->get('timeblocks');

foreach($collection as $item) {}
echo $this->formLabel($item->get('event_timeblock_label'));