List Info

Thread: Problems with slicing




Problems with slicing
user name
2007-02-18 15:01:09
Hi everyone

Have got Magpie up and running at
http:/
/lgsearch.net/rss/scripts/searchplus.php - however,
you'll see
that one of the feeds is huge and I need to slice them all
at 10, or
even 5. But when I copy the code in to do so, it doesn't do
anything!

Here's how my code appears:


	$rss = fetch_rss( 'feedurl' );

$items = array_slice($rss->items, 0, 10);
	echo $rss->channel['title'] . "<p>";
	echo "<ul>";
	foreach ($rss->items as $item) {
		$href = $item['link'];
		$title = $item['title'];	
		echo "<li><a
href=$href>$title</a></li>";

I think I have the slice code in the right place... Any
ideas on
what's going wrong?

Thanks in advance!

-- 
Dave Briggs

------------------------------------------------------------
-------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the
chance to share your
opinions on IT & business topics through brief
surveys-and earn cash
http://www.techsay.com/default.
php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Magpierss-general mailing list
Magpierss-generallists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/magpi
erss-general

Re: Problems with slicing
user name
2007-02-18 16:39:03
The problem is that you sliced the array, but then you used the original array instead of the slice.
change this:
&nbsp; &nbsp; &nbsp; &nbsp; foreach ($rss->items as $item) {
to this:
&nbsp; &nbsp; &nbsp; &nbsp; foreach ($items as $item) {

Russ

On 2/18/07, Dave Briggs < briggs.davegmail.com">briggs.davegmail.com> wrote:
Hi everyone

Have got Magpie up and running at
http://lgsearch.net/rss/scripts/searchplus.php - however, you'll see
that one of the feeds is huge and I need to slice them all at 10, or
even 5. But when I copy the code in to do so, it doesn't do anything!

Here's how my code appears:


 &nbsp; &nbsp; &nbsp; &nbsp;$rss = fetch_rss( 'feedurl' );

$items = array_slice($rss->items, 0, 10);
&nbsp; &nbsp; &nbsp;   ;echo $rss->channel[';title'] . "<p>";
 &nbsp; &nbsp; &nbsp;  echo "<ul>";;
 &nbsp; &nbsp;   ; foreach ($rss->items as $item) {
 &nbsp; &nbsp;   ; &nbsp; &nbsp; &nbsp; &nbsp; $href = $item[';link'];
 &nbsp; &nbsp; &nbsp;   ; &nbsp; &nbsp; &nbsp; $title = $item[';title'];
   ; &nbsp; &nbsp; &nbsp; &nbsp;   ; &nbsp;echo "<li><a href=$href>$title&lt;/a>&lt;/li>&quot;;

I think I have the slice code in the right place... Any ideas on
what9;s going wrong?

Thanks in advance!

--
Dave Briggs

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Magpierss-general mailing list
Magpierss-generallists.sourceforge.net">Magpierss-generallists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/magpierss-general

Re: Problems with slicing
user name
2007-02-19 02:22:04
Russ, that's great! Thanks for the help!

Dave

On 2/18/07, Russ Johnston <russstaceyshouse.com>
wrote:
> The problem is that you sliced the array, but then you
used the original
> array instead of the slice.
> change this:
>         foreach ($rss->items as $item) {
> to this:
>         foreach ($items as $item) {
>
> Russ
>
>
> On 2/18/07, Dave Briggs <briggs.davegmail.com> wrote:
> >
> > Hi everyone
> >
> > Have got Magpie up and running at
> > http:/
/lgsearch.net/rss/scripts/searchplus.php - however,
> you'll see
> > that one of the feeds is huge and I need to slice
them all at 10, or
> > even 5. But when I copy the code in to do so, it
doesn't do anything!
> >
> > Here's how my code appears:
> >
> >
> >         $rss = fetch_rss( 'feedurl' );
> >
> > $items = array_slice($rss->items, 0, 10);
> >         echo $rss->channel['title'] .
"<p>";
> >         echo "<ul>";
> >         foreach ($rss->items as $item) {
> >                 $href = $item['link'];
> >                 $title = $item['title'];
> >                 echo "<li><a
href=$href>$title</a></li>";
> >
> > I think I have the slice code in the right
place... Any ideas on
> > what's going wrong?
> >
> > Thanks in advance!
> >
> > --
> > Dave Briggs
> >
> >
>
------------------------------------------------------------
-------------
> > Take Surveys. Earn Cash. Influence the Future of
IT
> > Join SourceForge.net's Techsay panel and you'll
get the chance to share
> your
> > opinions on IT & business topics through brief
surveys-and earn cash
> >
> http://www.techsay.com/default.
php?page=join.php&p=sourceforge&CID=DEVDEV
> > _______________________________________________
> > Magpierss-general mailing list
> > Magpierss-generallists.sourceforge.net
> >
> https://lists.sourceforge.net/lists/listinfo/magpi
erss-general
> >
>
>


-- 
Dave Briggs

------------------------------------------------------------
-------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the
chance to share your
opinions on IT & business topics through brief
surveys-and earn cash
http://www.techsay.com/default.
php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Magpierss-general mailing list
Magpierss-generallists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/magpi
erss-general

[1-3]

about | contact  Other archives ( Real Estate discussion Medical topics )