php list & each example code_PHP tutorial

WBOY
Release: 2016-07-20 11:02:12
Original
856 people have browsed it

PHP list & each example code 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 ​

php tutorial list & each example code
Definition and Usage
The each() function generates an array consisting of the key name and key value of the element currently pointed to by the 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.

*/
$sports = array(
'football' => 'good',
'swimming' => 'very www.bkjia.com',
'running' => 'not good');

while (list($key,$value) = each($sports))
{
echo $key.": ".$value."
";
}
/*


Definition and Usage
The list() function assigns values ​​to a set of variables using elements in an array.

Note that, like array(), list() is actually a language construct, not a function.

*/

$sports = array(
'football' => 'good',
'swimming' => 'very well',
'running' => 'not www.bkjia.com');
while ($elem = each($sports)) {
echo $elem['key'].": ".$elem['value']."
";
}


www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/445394.htmlTechArticlephp list each example code definition and usage each() function generates an element pointed to by the current internal pointer of the array An array composed of key names and key values, and moves the internal pointer forward PHP teaches...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!