|
|
Unable to open remote file.\n";
exit;
}
function get_link($link)
{
if (eregi("
(.*)", $link, $out))
{
$result = $out[1];
return $result;
}
}
//function for getting the title -->
function get_title($title)
{
if (eregi("
(.*)", $title, $out))
{
$result = $out[1];
return $result;
}
}
//function for getting the description -->
function get_desc($desc)
{
if (eregi("
(.*)", $desc, $out))
{
$result = $out[1];
return $result;
}
}
//set up arrays that stores link,title and Description -->
$links_arr = Array();
$title_arr = Array();
$desc_arr = Array();
//Loop through rss file and ectract title, link and description -->
while (!feof ($file)) {
$line = fgets ($file, 4096);
// echo $line."
";
$line = str_ireplace("
","
No summary available",$line);
$line = str_ireplace("
","
No description available",$line);
// echo $line."
";
//Grab and store if there is valid title, link and the description -->
//$title = get_title($line);
$title = get_title($line);
if ($title)
{
$title_arr[]= $title;
// echo $title." ";
}
$link = get_link($line);
if ($link)
{
$links_arr[]= $link;
// echo $link."
";
}
$desc = get_desc($line);
if ($desc)
{
$desc_arr[]= $desc;
// echo $desc."
";
}
}
// Test for array title array
$title_count = count($title_arr);
// echo "array elements: ".$title_count."
";
$_SESSION['titles'] = $title_arr;
$_SESSION['stories'] = $story_arr ;
$_SESSION['descriptions'] = $desc_arr ;
$_SESSION['links'] = $links_arr;
//print "
the number of titles are $title_count
";
for($i = 1; $i <= $title_count; $i++ )
{
// print the links by using link_array and the title_array
print"
";
print "".$title_arr[$i].'
';
// print the description
print $desc_arr[$i];
print"
";
//print "\n";
}
fclose($file);
?>