PHP each() Function

The each() function is used to fetch the key and value of the current element. The function also moves the internal array pointer forward.Return the current key and value pair from an array and advance the array cursor.The each() function returns the current element key and value, and moves the internal pointer forward.This element key and value is returned in an array with four elements. Two elements (1 and Value) for the element value, and two elements (0 and Key) for the element key.

Example -

Example -