Hi,
I have an array form of data from an RSS feed (XML file) and I am trying to print out the news topics but having a problem displaying it,
My code so far:
require("inc.rss2array.php");
$rss_array = rss2array("http://newsrss.bbc.co.uk/rss/newsonline_world_edition/technology/rss.xml");
print "<pre>";
print_r($rss_array);
print "</pre>";
I used the above to print out what ws in the array and get:
Array
(
[inside_image] =>
[items] => Array
(
[0] => Array
(
[title] => Tiny drives set for space boost
[link] =>
http://news.bbc.co.uk/go/rss/-/2/hi/...gy/4411649.stm
[description] => Hitachi demonstrates a leap in hard drive technology which will lead to one-inch hard drives that can hold 60GB.
)
[1] => Array
(
[title] => Google to start 'video blogging'
[link] =>
http://news.bbc.co.uk/go/rss/-/2/hi/...gy/4412125.stm
[description] => Search engine firm Google is to begin an experiment in "video blogging", according to co-founder Larry Page.
)
[2] => Array
---------cut for reasons of space and patience!!!-------------
)
[channel] => Array
(
[title] => BBC News | Technology | World Edition
)
)
.....but keep getting errors on the foreach loop around the array, like this:
foreach ($rss_array as $item){
echo "item: $item<br>";
foreach ($item as $subitem){
echo "subitem: $subitem<br>";
foreach ($subitem as $subsubitem){
echo "subsubitem: $subsubitem<br>";
}
}
}
like:
Warning: Invalid argument supplied for foreach() on line 23 -----line 23 is: foreach ($item as $subitem)
at the start of the loop and
Warning: Invalid argument supplied for foreach() on line 26 -----line 26 is: foreach ($subitem as $subsubitem)
at the end of the loop, I also only want to print out say the first 10 records too?
Hope you can help
Many Thanks
Sami