2010-11-21 7 views
1

特定のタグが該当する場合のみ、特定のフィードソースからフィードニュースを取得したいと考えています。Zend_Feed_Rss - 私はエコーすることはできますが、何もできません。

$ 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; 
     } 
    } 

はしかし、: エコー$カテゴリは」私は、ビューポートに印刷すべてのカテゴリを取得

私はここで何を取得していない午前くださいアドバイス、 MEM

UPDATE:。? 私が行う場合 を::シンプルに言えば 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

答えて

0

文字列:(string)$categoryにキャストしようとします。私はあなたがあなたの場合はthis page of the manual

foreach ($channel as $item) { 
    echo $item->title() . "\n"; 
} 

を探している、これは動作するはずだと思う

1

(私はあなたに戻って来る、それが動作しない場合を教えて、今すぐ試すことができません後で):

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'; 
    } 
} 
関連する問題