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
  • Calculate the number of units in an array, or the number of attributes in an object count

    count

    Calculatethenumberof
  • Return all values ​​in the array array_values

    array_values

    Returnallvalues​​int
  • Point the inner pointer of the array to the first unit reset

    reset

    Pointtheinnerpointer
  • Alias ​​for current pos

    pos

    Alias​​forcurrent
  • Assign values ​​from an array to a set of variables list

    list

    Assignvalues​​froman
  • Calculate the differences in arrays array_diff

    array_diff

    Calculatethedifferen
  • Create an array including variable names and their values compact

    compact

    Createanarrayincludi
  • Calculate the intersection of the array and compare the data using the callback function array_uintersect

    array_uintersect

    Calculatetheintersec
Popular Articles