Log in

View Full Version : Random Feed



*Warrior*
07-09-2008, 03:06 AM
Ok I edited and updated this post ..


<?php
function GetFeed($feedurl)
{
$DOM = new DOMDocument();
$DOM->load($feedurl);

$feed = $DOM->getElementsByTagName("item");
$number = 0;
foreach($feed as $feedvalue) {
$feedtitles = $feedvalue->getElementsByTagName("title");
$feedtitle = $feedtitles->item(0)->nodeValue;
$feedtexts = $feedvalue->getElementsByTagName("description");
$feedtext = $feedtexts->item(0)->nodeValue;
$feedurls = $feedvalue->getElementsByTagName("link");
$feedurl = $feedurls->item(0)->nodeValue;
if($number<2){
echo('<a href="'.$feedurl.'" ><h4>'.$feedtitle.'</h4></a><br/>'.$feedtext."<br/><br/>");
$number++;
}
}
}

GetFeed('http://feeds.feedburner.com/SmashingMagazine');
GetFeed('http://feeds.feedburner.com/urbanspy');
GetFeed('http://feeds.feedburner.com/core77/blog');

?>

I have that code right but I need the GetFeed's to randomize ... Now I don't know much about php and yes I am asking for some examples but if you know what you doing then please show me..

I friend said sumthing about array's would that work? and hrrmm how do they work?

*Warrior*
07-12-2008, 08:40 PM
Bump

(I updated my post)

dicegame
07-13-2008, 01:57 PM
You want the output to be randomised?

*Warrior*
07-17-2008, 02:03 AM
yup...

I looked into array's and then tried using that and a randomize code thing but that failed any1 got any idea's?

dicegame
07-17-2008, 07:25 AM
http://au2.php.net/manual/en/function.shuffle.php

From php.net:

"Note: This function assigns new keys to the elements in array . It will remove any existing keys that may have been assigned, rather than just reordering the keys."