[英]Zend_Feed_Rss - I can echo but I can't do anything else?
我想从给定的提要源中检索一些提要新闻,只有在使用特定标签的情况下。
我不明白,因为$ category不是字符串,因此不会返回strschr。 (所以我相信)。
function ultimasNoticiasBlog()
{
$channel = new Zend_Feed_Rss('http:/something.com/?feed=rss2');
$news = array();
foreach ($channel as $item) {
foreach ($item->category as $category)
{
//if any of the news has the tag "Sugestão"
if (strchr($category,'Sugestão'))
{
$news['find'] = "I have found a feed with your tag";
}
else
{
echo 'Found Nothing';
}
}
return $news;
}
}
但是,如果这样做:echo $ category“,我将在视口上打印所有类别。
我什么不来? 请指教,MEM
更新:简而言之: 如果我这样做: var_dump($category);
我得到:
object(Zend_Feed_Element)#159 (3) {
["_element:protected"]=>
object(DOMElement)#165 (0) {
}
["_parentElement:protected"]=>
NULL
["_appended:protected"]=>
bool(true)
}
object(Zend_Feed_Element)#156 (3) {
["_element:protected"]=>
object(DOMElement)#166 (0) {
}
["_parentElement:protected"]=>
NULL
["_appended:protected"]=>
bool(true)
}
如果我这样做: echo $ category;
我进入查看端口:SugestaoAnotherTag1AnotherTag2 ...
我不明白为什么,更重要的是,我不知道如何才能看到“ Sugestao是否是这种情况”。 :s
我认为您正在寻找手册的这一页
foreach ($channel as $item) {
echo $item->title() . "\n";
}
在您的情况下,这应该可以解决(现在无法尝试,告诉我是否无法解决,我稍后会再与您联系):
foreach ($channel as $item) {
//if any of the news has the tag "Sugestão"
if (strchr($item->category(),'Sugestão')){
return "I have found a feed with your tag";
}else {
return 'Found Nothing';
}
}
尝试将其转换为string: (string)$category
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.