26. Array Manipulations each() function Returns the current key and value pair from the array array and advances the array cursor. This pair is returned in a four-element array, with the keys 0, 1, key, and value. Elements 0 and key contain the key name of the array element, and 1 and value contain the data. <?php $fruit = array( 'a' => 'apple' , 'b' => 'banana' , 'c' => 'cranberry' ); reset ( $fruit ); while (list( $key , $val ) = each ( $fruit )) { echo "$key => $val" ; } ?> The above example will output: copy to clipboard a => apple b => banana c => cranberry
27. <?php $array = array( 'step one' , 'step two' , 'step three' , 'step four' ); // by default, the pointer is on the first element echo current ( $array ) . "<br />" ; // "step one" // skip two steps next ( $array ); next ( $array ); echo current ( $array ) . "<br />" ; // "step three" // reset pointer, start again on step one reset ( $array ); echo current ( $array ) . "<br />" ; // "step one" ?> reset() function rewinds array's internal pointer to the first element and returns the value of the first array element, or FALSE if the array is empty.