我在使用Amazon PHP SDK提取Tags部分中的卷名时遇到了一些问题。
我可以打印卷ID,但由于标签在一个单独的数组中,我不知道如何引用名为"名称"的密钥的值。
$east_client=''Aws''Ec2''Ec2Client::工厂($east_config);$east_result=$east_client->describeVolumes();$east_volumes=$east_result['volumes'];foreach($east_volumes为$e){echo$e['VolumeId']。"''n";}
以下是describeVolumes()
的API文档,以防您尚未看到它们:http://docs.aws.amazon.com/aws-sdk-php-2/latest/class-Aws.Ec2.Ec2Client.html#_describeVolumes.
试试这样的东西:
foreach ($volumes as $volume) {
echo "{$volume['VolumeId']}'n";
foreach ($volume['Tags'] as $tag) {
echo "- {$tag['Key']}: {$tag['Value']}'n";
}
echo "'n";
}