11.07.2015 Views

PHP MySQL - Stilson.net

PHP MySQL - Stilson.net

PHP MySQL - Stilson.net

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

www.it-ebooks.infoCHAPTER 5 • ARRAYSThe output follows:Can you name the states belonging to these capitals?ColumbusDes MoinesRetrieving the Current Array Key and ValueThe each() function returns the current key/value pair from the array and advances the pointer oneposition. 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 1and value containing the corresponding data. If the pointer is residing at the end of the array beforeexecuting each(), FALSE is returned.Moving the Array PointerSeveral functions are available for moving the array pointer. These functions are introduced in thissection.Moving the Pointer to the Next Array PositionThe next() function returns the array value residing at the position immediately following that of thecurrent array pointer. Its prototype follows:mixed next(array array)An example follows:$fruits = array("apple", "orange", "banana");$fruit = next($fruits); // returns "orange"$fruit = next($fruits); // returns "banana"Moving the Pointer to the Previous Array PositionThe prev() function returns the array value residing at the location preceding the current pointerlocation, 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.115

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!