each() definition and usage
each() function generates an array consisting of the key name and key value of the element pointed to by the current internal pointer of the array, and moves the internal pointer forward.
The returned array includes four elements: key names 0, 1, key and value. Cells 0 and key contain the key names of the array cells, and 1 and value contain the data.
If the internal pointer exceeds the range of the array, this function will return FALSE.
Syntax
each(array) Parameter Description
array Required. Specifies the array to use.
Example 1
Copy the code The code is as follows:
$people = array("Peter", "Joe", "Glenn", "Cleveland");
print_r (each($ people));
?>
Copy code The code is as follows:
$people = array("Peter", "Joe", "Glenn", "Cleveland");
reset($people);
while (list($key, $val) = each($people))
{
echo "$key => $val
";
}
?>
The above introduces the PHP array PHP array function sequence each - obtains the key name and key value of the element pointed to by the current internal pointer of the array, and moves the pointer to the next position, including PHP array content. I hope you are interested in PHP tutorials. Friends help.