I'm trying to randomly select 5 entries from an array taken from an RSS feed.
I think I have the basics, but something must be way off at the same time...
$content = file_get_contents($feed);
$x = new SimpleXmlElement($content);
$feed = array();
foreach($x->channel->item as $entry){
$value = '<p><a href="' .$entry->link. '">' .$entry->title. '</a><br />';
$value .= $entry->description;
$feed[$entry->id] = $value;
}
while($a < 5){
echo $feed[array_rand($feed)];
$a++;
}
The error I get says it's an illegal offset type at line: $feed[$entry->id] = $value;
Any suggestions?