我有以下代码片段。
$items['A'] = "Test";
$items['B'] = "Test";
$items['C'] = "Test";
$items['D'] = "Test";
$index = 0;
foreach($items as $key => $value)
{
echo "$index is a $key containing $value\n";
$index++;
}
预期输出:
0 is a A containing Test
1 is a B containing Test
2 is a C containing Test
3 is a D containing Test
有没有办法省略$index
变量?