2010-03-03 101 views
0

進出口使用鵲RSS解析器(http://magpierss.sourceforge.netPHP RSS解析器(喜鵲)深元素

這裏是vardump:

array(11) { 
    ["dc"]=> 
    array(1) { 
    ["creator"]=> 
    string(9) "Microsoft" 
    } 
    ["title"]=> 
    string(16) "The Type We Want" 
    ["description"]=> 
    string(245) "After a slow evolution, the landscape for custom type on the web has been changing quickly. This session will cover the history of embedding fonts, diving into the options available to us today and finally taking a look at the hurdles before us." 
    ["link"]=> 
    string(44) "http://live.visitmix.com/MIX10/Sessions/DS15" 
    ["guid"]=> 
    string(44) "http://live.visitmix.com/MIX10/Sessions/DS15" 
    ["pubdate"]=> 
    string(29) "Tue, 02 Mar 2010 09:51:34 GMT" 
    ["category"]=> 
    string(2) "UX" 
    ["evnet"]=> 
    array(6) { 
    ["starttime"]=> 
    string(29) "Wed, 17 Mar 2010 09:00:00 GMT" 
    ["endtime"]=> 
    string(29) "Wed, 17 Mar 2010 10:00:00 GMT" 
    ["location"]=> 
    string(9) "Lagoon GH" 
    ["speaker"]=> 
    string(17) " 
       " 
    ["speaker_displayname"]=> 
    string(14) "Jonathan Snook" 
    ["speaker_moreinfo"]=> 
    string(48) "http://live.visitmix.com/Speakers/Jonathan-Snook" 
    } 
    ["speaker"]=> 
    string(30) " 

      " 
    ["summary"]=> 
    string(245) "After a slow evolution, the landscape for custom type on the web has been changing quickly. This session will cover the history of embedding fonts, diving into the options available to us today and finally taking a look at the hurdles before us." 
    ["date_timestamp"]=> 
    int(1267523494) 
} 

我想呼應這些元素:

["evnet"]=> 
     array(6) { 
     ["starttime"]=> 
     string(29) "Wed, 17 Mar 2010 09:00:00 GMT" 
     ["endtime"]=> 
     string(29) "Wed, 17 Mar 2010 10:00:00 GMT" 
     ["location"]=> 
     string(9) "Lagoon GH" 
     ["speaker"]=> 
     string(17) " 
        " 
     ["speaker_displayname"]=> 
     string(14) "Jonathan Snook" 
     ["speaker_moreinfo"]=> 
     string(48) "http://live.visitmix.com/Speakers/Jonathan-Snook" 
     } 

我已有:

<?php require_once('magpie/rss_fetch.inc'); 
$rss = fetch_rss('http://live.visitmix.com/Sessions/RSS'); 

foreach ($rss->items as $item) { 
     $href = $item['link']; 
     $title = $item['title']; 
     $desc = $item['description']; 
     $cat = $item['category']; 
     echo '<p><a href="$href">'.$title.'</a><br>'; 
     if($desc) echo $desc; 

} 



?> 

任何人都可以幫助我回應那些似乎在數組中的項目?

例如$cat = $item['starttime'];不起作用。

+0

詳細說明,我沒看到問題。 – casraf 2010-03-03 19:23:09

+0

我不知道如何獲得'evnet'元素。 – CLiown 2010-03-03 19:31:22

回答

0
foreach($rss->items as $item) { 
    // ... 
    $event = $item['evnet']; 
    $start = $event['starttime']; 
    // ... 
} 
1

$ cat = $ item ['evnet'] ['starttime'];