|
Posted by Vince Morgan on 04/26/07 12:30
"zach" <wackzingo@gmail.com> wrote in message
news:vJKdnVn6DcAwCq3bnZ2dnUVZ_ubinZ2d@wavecable.com...
> Vince Morgan wrote:
> > "Vince Morgan" <vinhar@REMOVEoptusnet.com.au> wrote in message
> > news:463070bb$0$5743$afc38c87@news.optusnet.com.au...
> >> "zach" <wackzingo@gmail.com> wrote in message
> >> news:F7SdnewfZeP1na3bnZ2dnUVZ_gCdnZ2d@wavecable.com...
> >>> Hello everyone,
> >>>
> >>> I was looking for short simple script to show rss feeds on my website
> >>> and I found this one and it works awesome except I don't know what to
> >>> add or modify to limit the number of entries it shows. The entire
script
> >>> is posted below. Thanks in advance for the help.
> >>>
> > Too hurried sorry. Made an error
> >
> >> funcion chopRss($fileIn, $fileOut, $noItems)
> > First param is the name of the rss file you want to chop, second is the
file
> > to write the results to, and the last is the number of items you want.
> >
> > function chopRss($fileIn, $fileOut, $noItems=1)
> > {
> > $reRss=file_get_contents($fileIn);
> > $ary=spliti('<item>', $reRss);
> > $limit=$noItems;
> > $reRss='';
> > $i=0;
> > while($i < $noItems)
> > {
> > $reRss.=$ary[$i];
> > ++$i;
> > }
> > $reRss.='</channel></rss>';
> > file_put_contents($fileOut, $reRss);
> > )
> >
> >
>
> Awesome, thanks...I'll try it when I get home later.
There is some room for failure in the above code Zach. If the number of
items you want is greater than the number actualy in the original file you
will get an "undefined index" error.. It doesn't check that the file path
is valid, and it will overwrite the destination file without warning.
$limit is an artifact that I forgot to eliminate when I wrapped the code
into a function.
In other words, there is a little work for you to do too ;)
Navigation:
[Reply to this message]
|