I'm trying to create an array of items from an RSS feed. I'm trying to test if it's working by echoing the title of the first item. I've been unsuccessful so far...I'd really appreciate any advice!
I have two files, an 'index.php' and a 'test.php'.
<!DOCTYPE html>
<html>
<head>
<link rel = "stylesheet" type= "text/css" href = "style.css">
</head>
<body>
<h1>TEST SLIDER</h1>
<p>First Title:<br>
<?php
    include 'test.php';
    $NPR_url = 'http://www.npr.org/rss/rss.php?id=1001';
    $NPR = GetFeed($NPR_url);
    echo $NPR[0]['title'];
?>
</p>
</body>
</html>
and 'test.php'
<?php
    function GetFeed($url){
        $feed = new DOMDocument;
        $feed->load($url);
        $feed_array = array();
        foreach($feed->getElementsByTagName('item') as $story){
            $story_array = array (
                                  'title' => $story->getElementsByTagName('title')->item(0)->nodeValue,
                                  'desc' => $story->getElementsByTagName('description')->item(0)->nodeValue,
                                  'link' => $story->getElementsByTagName('link')->item(0)->nodeValue,
                                  'date' => $story->getElementsByTagName('pubDate')->item(0)->nodeValue
            );
            array_push($feed_array, $story_array);
        }
        return $feed_array;
    }
?>
 
     
    