次のコード スニペットがあります。
$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
変数を除外する方法はありますか?