PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098 Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia
Post
by Chris Corbyn » Tue Apr 06, 2004 9:09 pm
Hi,
How do you only use say the first 25 elements of an array in a foreach loop?
There are hundreds of elements in my array but I only want to do things with the first 25 in the loop.
Thanks
markl999
DevNet Resident
Posts: 1972 Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)
Post
by markl999 » Tue Apr 06, 2004 9:17 pm
foreach(array_slice($thearray, 0, 25) as $foo){
...
}
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098 Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia
Post
by Chris Corbyn » Tue Apr 06, 2004 9:21 pm
Works a treat. Never spotted that function in the manual.
Thanks for fast reply!