> > This is my attempt to count items and put a stop in the foreach so it only > > returns 5 items. > > > > foreach ($this->_content as $n => $item) { > > if ($n=="5") > > > break; > > } else > > > if ($this->_content[$n] => $item['type'] == 'item'){ > > $elements['ITEM_LINK'] = $this->_content[$n] => $item['link']; > > $elements['ITEM_TITLE'] = $this->_content[$n] => > $item['title']; > > $elements["TARGET"] = $this->_target; > > $items .= PHPWS_Template::processTemplate($elements, > > "phpwsrssfeeds", "block_item.tpl"); > > } > > } > > } > > Why don't you use a for() loop to restrict to 5 loops?: > > $count = count($this->_content); > for ($i; $i < 5; $i++) { > ... > } > > > > > Php doesn't like the syntax on any of the, > > $this->_content[$n] => $item['type'] > > Because => is a foreach() specific syntax. As far as I understand you don't > need $this->_content[$n] as this is the same as $item, so just omit > '$this->_content[$n] =>': > > if ($item['type'] == 'item'){ > $elements['ITEM_LINK'] = $item['link']; > $elements['ITEM_TITLE'] = $item['title']; > $elements["TARGET"] = $this->_target; > $items .= PHPWS_Template::processTemplate($elements, > "phpwsrssfeeds", "block_item.tpl"); > }
Sorry, I mixed up the for and the foreach syntaxes. Here my (hopefully correct) loop proposal: for ($i; $i < 5; $i++) { if (is_array($this->_content) && is_array($this->_content[$i]) && $this->_content[$i]['type'] == 'item') { $elements['ITEM_LINK'] = $this->_content[$i]['link']; $elements['ITEM_TITLE'] = $this->_content[$i]['title']; $elements['TARGET'] = $this->_target; $items .= PHPWS_Template::processTemplate($elements, 'phpwsrssfeeds', 'block_item.tpl'); } } $elements and items should be initialized before the loop. > > Please try and report if it helped. > > Regards, Torsten > > > , etc lines > > > > > > TIA, > > Verdon -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php