Thanks again. It's working now and I don't quite know how to explain the previous error.
Here's the working code...
The function I'm using:
PHP Code:
function readSzBlog() {
$data = file_get_contents("http://www.undisclosed.com/feeds/blog");
$data = simplexml_load_string($data);
$entries = array();
foreach($data->entry as $entry)
{
$entries[] = array
(
'title' => (string)$entry->title,
'summary' => (string)$entry->summary,
);
}
$first[] = $entries[0];
return($first);
};
And the output side:
PHP Code:
<?php
foreach(readSzBlog() as $post)
{
?>
<h2><?php echo($post['title']); ?></h2>
<div><?php echo($post['summary']); ?></div>
<?php
}
?>
With this particular XML file currently I don't suppose it matters because it's actually quite small, but in the tutorial (using the BBC News feed) there was quite a delay in receiving the feeds. Considering I only want the contents of the first entry would it not be better to just load that rather than loading the whole file and then not using most of it? Or is that just asking too much?
Cheers,
dog
Bookmarks