Re: Limit iterations on a foreach loop?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, 2005-02-10 at 15:58 -0800, Brian Dunning wrote:
> I'm using an RSS feed that has WAY too much content, I only want the 
> first 10. I'm outputting the array with a foreach loop: is there a way 
> to limit it to only go through the first 10?
> 
> Thanks,
> 
> - Brian
> 

Is this data coming from a database? If so, just set a limit at the end
of your query...

example: SELECT * FROM blog ORDER BY id DESC LIMIT 10;

..will return the latest 10 entries.

-Robby

-- 
/***************************************
* Robby Russell | Owner.Developer.Geek
* PLANET ARGON  | www.planetargon.com
* Portland, OR  | robby@xxxxxxxxxxxxxxx
* 503.351.4730  | blog.planetargon.com
* PHP/PostgreSQL Hosting & Development
* --- Now hosting Ruby on Rails Apps ---
****************************************/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux