迭代和迭代器
迭代是指反复执行一个过程,每执行一次叫做一次迭代.
<?php
$mapping = [
'red' => '#FF0000',
'green' => '#00FF00',
'blue' => '#0000FF'
];
foreach ($mapping as $key => $value) {
printf("key: %d - value: %s\n", $key, $value);
}
迭代是指反复执行一个过程,每执行一次叫做一次迭代.
<?php
$mapping = [
'red' => '#FF0000',
'green' => '#00FF00',
'blue' => '#0000FF'
];
foreach ($mapping as $key => $value) {
printf("key: %d - value: %s\n", $key, $value);
}
本文标题:php生成器的使用
本文链接:https://www.haomeiwen.com/subject/rodsxctx.html
网友评论