[英]Zend_Feed_Rss - I can echo but I can't do anything else?
I would like to retrieve some feed news from a given feed source, only if a specific tag is the case. 我想从给定的提要源中检索一些提要新闻,只有在使用特定标签的情况下。
I'm not getting it, because $category is not a string, hence strschr will not returned. 我不明白,因为$ category不是字符串,因此不会返回strschr。 (so I believe). (所以我相信)。
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;
}
}
However, if I do: echo $category" I get all categories printed on the viewport. 但是,如果这样做:echo $ category“,我将在视口上打印所有类别。
What am I not getting here? 我什么不来? Please advice, MEM 请指教,MEM
UPDATE: To put it simple: If I do: var_dump($category);
更新:简而言之: 如果我这样做: var_dump($category);
I get: 我得到:
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)
}
If I do: echo $category; 如果我这样做: echo $ category;
I get on the view port: SugestaoAnotherTag1AnotherTag2 ... 我进入查看端口:SugestaoAnotherTag1AnotherTag2 ...
I'm not understanding why and, more important, I'm not seeing how can I then see if "Sugestao is the case or not". 我不明白为什么,更重要的是,我不知道如何才能看到“ Sugestao是否是这种情况”。 :s :s
I think you're looking for this page of the manual 我认为您正在寻找手册的这一页
foreach ($channel as $item) {
echo $item->title() . "\n";
}
In your case, this should work (can't try right now, tell me if it doesn't work, I'll come back to you later): 在您的情况下,这应该可以解决(现在无法尝试,告诉我是否无法解决,我稍后会再与您联系):
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.