In anticipation of this, you cannot do this. There are only two ways to get what you want:
- Use the for loop and start at position 1
- use foreach and use something like if ($ key> 0) around your actual code.
A foreach does what his name tells you. Doing something for each element :)
EDIT : OK, a very bad decision came to my mind. Try the following:
foreach(array_reverse(array_pop(array_reverse($array))) as $key => $value){ ... }
This will change the array, pull out the last element and undo it again. Then you will have an element that excludes the first.
But I would recommend using one of the other solutions. Best will be first.
And option: you can use array_slice () for this:
foreach(array_slice($array, 1, null, true) as $key => $value){ ... }
But you must use all three parameters to save the array keys for your foreach loop:
2ndkauboy Jul 12 '10 at 15:52 2010-07-12 15:52
source share