Current Location: Home> Function Categories> each

each

Return the current key/value pair in the array and move the array pointer forward one step - this function has been abandoned since PHP 7.2.0. It is strongly recommended not to use this function.
Name:each
Category:Array
Programming Language:php
One-line Description:Returns the current key/value pair in the array.

Definition and usage

each() function returns the key name and key value of the current element and moves the internal pointer forward.

The key name and key value of this element are returned to an array with four elements. Two elements (1 and Value) contain key values, and two elements (0 and Key) contain key names.

Related methods:

  • current() - Returns the value of the current element in the array
  • end() - Point the inner pointer to the last element in the array and output
  • next() - Points the inner pointer to the next element in the array and outputs
  • prev() - Point the inner pointer to the previous element in the array and output
  • reset() - Points the inner pointer to the first element in the array and outputs

grammar

 Each ( array )
parameter describe
array Required. Specifies the array to be used.

illustrate

each() function generates an array consisting of the key names and key values ​​of the elements pointed to by the current internal pointer of the array, and moves the internal pointer forward.

The returned array contains four elements: key names 0, 1, key, and value. Unit 0 and key contain the key names of the array units, and 1 and value contain the data.

If the internal pointer exceeds the array range, this function returns FALSE.

Similar Functions
Popular Articles