Results 1 to 5 of 5

Thread: Random Feed

  1. #1
    Join Date
    Jun 2007
    Posts
    18
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Random Feed

    Ok I edited and updated this post ..

    Code:
    <?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?
    Last edited by *Warrior*; 07-12-2008 at 08:40 PM.

  2. #2
    Join Date
    Jun 2007
    Posts
    18
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    Bump

    (I updated my post)

  3. #3
    Join Date
    Jul 2008
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    You want the output to be randomised?

  4. #4
    Join Date
    Jun 2007
    Posts
    18
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    yup...

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

  5. #5
    Join Date
    Jul 2008
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    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."

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •