Each---Returns key/http://www.aliyun.com/zixun/aggregation/9541.html from the array ">value
Syntax: array each (array array);
Description:
Returns the current Key/value pair from an array of arrays, and moves the array cursor (cursor) forward. The returned array has four elements, 0, 1, key, and value respectively. Element 0 and key are the names of the array index values, and 1 and value are the data for the element. This function returns false if the internal index of the array refers to the end of the array.
Example:
<?php
$foo = Array ("Bob", "Fred", "Jussi", "Jouni");
$bar = each ($foo);
?>
$bar now contains the following key/value pairs:
0 => 0 1 => ' Bob ' Key => 0 Value => ' Bob ' <?php
0 => ' Robert ' 1 => ' Bob ' Key => ' Robert ' Value => ' Bob ' Each is usually used with the list, for example: $HTTP _post_vars
Example:
<?php
echo "Values submitted via POST method:<br>";
while (the list ($key, $val) = each ($HTTP _post_vars)) {
echo "$key => $val <br>";
}
?>
After each () is executed, the array's cursor (cursor) will be on the left side of the next element of the array, and if the end of the array is reached, the cursor is at the last element.
Reference: Key () current () reset () Next () prev ()
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.