I'm trying to get the items form an rss feed so I can display them on my blog. For some reason when I print_r an array outside the foreach loop it only displays one item instead of the two that are supposed to be there.
My foreach looks like this:
$arr_postContent = array();
foreach ($feed as $row) {
$feedid = $row->id;
$feedurl = $row->blogUrl;
foreach ($rss->getElementsByTagName('item') as $node) {
$item = array (
'title' => $node->getElementsByTagName('title')->item(0)->nodeValue,
'link' => $node->getElementsByTagName('link')->item(0)->nodeValue,
);
$postContent = array('link' => $item['link'], 'title' => $item['title']);
$arr_postContent['site'] = $postContent;
}
[ STEP ONE ]
}
[ STEP TWO ]
Where I have put [ STEP ONE ] and [ STEP TWO ] I put the code:
echo '<pre>';
print_r($arr_postContent);
echo '</pre>';
[ STEP ONE ] gives me :
Array
(
[site] => Array
(
[link] => siteurl1
[title] => site title1
)
)
Array
(
[site] => Array
(
[link] => siteurl2
[title] => site title2
)
)
[ STEP TWO ] gives me:
Array
(
[site] => Array
(
[link] => siteurl1
[title] => site title1
)
)
can someone tell me why It is only giving me one of the results and show me how to get both of them to output in [ STEP TWO ]?
Thanks