Jump to content

Filterout duplicate content from a RSS feed


forzatio

Recommended Posts

foreach ($rss->items as $item)  {



$description =  $item[description];
$url =		$item[link];
$title =	$item[title];


$array = array($title);
$array_unique = array_unique($array);

foreach ($array_unique as $value) {
    echo "$value<br><br>";	
}




}



 

I tried it like this, but I still get duplicate titles.

foreach ($rss->items as $item)  {



$description =  $item[description];
$url =		$item[link];
$title =	$item[title];


$array = array($description);
$array_unique = array_unique($array);

foreach ($array_unique as $value) {
    echo "$value<br><br>";	
}
}

 

I tried it with the description there are also some duplicates left in there,  can I do this code above ? it's a foreach in a foreach.. I'm not sure about my code.

Ok another try, with this code I want to get $description, $title and $url into arrays, and then use array_unique (in this example for the $title) with this code it's not giving any output though.

 

 

 

<?php require_once 'rss_fetch.inc';

$url = 'http://www.example.com/feed.rss';
$rss = fetch_rss($url);



foreach ($rss->items as $item)  {



$description =  array ($item[description]);
$url =		array ($item[link]);
$title =	array ($item[title]);



$array_unique = array_unique($title);

foreach ($array_unique as $value) {
    echo "$value<br><br>";	
}


?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.