English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
The each() function returns the current key/value pair from the array and moves the array pointer one step forward
each ($array);
The each() function returns the current key-value pair from the array array and advances the array cursor. The pair is returned in the form of a four-element array, with keys 0,1Key and value. Element 0 and key contain the name of the array element, element1and value contain data.
Serial Number | Parameters and Description |
---|---|
1 | array (required) It specifies an array |
It returns the current key-value pair from the array.
<?php $transport = array('foot', 'bike', 'car', 'plane'); $key_value = each($transport); print_r($key_value); print "<br />"; $key_value = each($transport); print_r($key_value); print "<br />"; $key_value = each($transport); print_r($key_value); ?>Test and See‹/›
Output Result:
Array ( [1] => foot [value] => foot [0] => 0 [key] => 0 ) Array ( [1] => bike [value] => bike [0] => 1 [key] => 1 ) Array ( [1] => car [value] => car [0] => 2 [key] => 2 )