-
SitePoint Zealot

simple array
hi
i have a simple array with 100 elements, but i need to use only the last 99 elements( without element[0] )
how can I do without iterating through the array from 1 to 100, using a for? do you have any smarter solution?
-
http://uk.php.net/manual/en/function.array-shift.php
$in = array(1,2,3,4, ..., 100);
$out = array_shift($in);
for ($i = 0; $i < count($out); $i++)
{
....
}
-
SitePoint Zealot

MANY THX.....this is really a smart thing
-
Even simpler, you could use array_slice() to take a copy of the part of the array you want, and iterate through that:
http://us.php.net/array_slice
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
Bookmarks