Its prototype follows:
array each(array array)
The returned array consists of four keys, with keys 0 and key containing the key
name, and keys 1 and value containing the corresponding data. If the pointer is
residing at the end of the array before executing each(), FALSE is returned.
Moving the Array Pointer
Several functions are available for moving the array pointer. These functions are
introduced in this section.
Moving the Pointer to the Next Array Position
The next() function returns the array value residing at the position immediately
following that of the current array pointer. Its prototype follows:
CHAPTER 5 ?– ARRAYS 141
mixed next(array array)
An example follows:
$fruits = array("apple", "orange", "banana");
$fruit = next($fruits); // returns "orange"
$fruit = next($fruits); // returns "banana"
You can also move the pointer backward, as well as directly to the beginning and
conclusion of the array. These capabilities are introduced next.
Moving the Pointer to the Previous Array Position
The prev() function returns the array value residing at the location preceding the
current pointer location, or FALSE if the pointer resides at the first position in the
array. Its prototype follows:
mixed prev(array array)
Because prev() works in exactly the same fashion as next(), no example is necessary.
Moving the Pointer to the First Array Position
The reset() function serves to set an array pointer back to the beginning of the array.
Pages:
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222