我目前正在使用 Amazon AWS SNS 向客户发送 SMS。我想简单地显示一个下拉菜单,topicArn每个选项都作为每个选项。我从我收到的回复中尝试了以下内容,var_dump($topics);但它不起作用。<div class="form-group"> <label for="exampleFormControlSelect1">Select list</label> <select class="form-control" name="selectList" id="selectList"> <?php $topics = $sns->listTopics(); $test = $topics->get('Topics'); foreach($test['TopicArn'] as $topicArns) { echo '<option>'.$topicArns.'</option>'; } ?> </select> </div>回复:object(Aws\Result)#109(2){ [ "data": "Aws\Result": private ]=>array(2){ [ "Topics" ]=>array(4){ [ 0 ]=>array(1){ [ "TopicArn" ]=>string(50)"arn:aws:sns:eu-west-1:547872464065:Custoddmers-Optin" }[ 1 ]=>array(1){ [ "TopicArn" ]=>string(42)"arn:aws:sns:eu-west-1:547872464065:Testing" }[ 2 ]=>array(1){ [ "TopicArn" ]=>string(55)"arn:aws:sns:eu-west-1:547872464065:test19-06-2019_02-19" }[ 3 ]=>array(1){ [ "TopicArn" ]=>string(57)"arn:aws:sns:eu-west-1:547872464065:tester19-06-2019_02-17" } }[ "@metadata" ]=>array(4){ [ "statusCode" ]=>int(200)[ "effectiveUri" ]=>string(35)"https://sns.eu-west-1.amazonaws.com"[ "headers" ]=>array(4){ [ "x-amzn-requestid" ]=>string(36)"92f435gd-8fd5-5c0e-ad5hd-bhb74hkd74c66d"[ "content-type" ]=>string(8)"text/xml"[ "content-length" ]=>string(3)"717"[ "date" ]=>string(29)"Wed, 19 Jun 2019 01:53:14 GMT" }[ "transferStats" ]=>array(1){ [ "http" ]=>array(1){ [ 0 ]=>array(0){ } } } } }
1 回答
Qyouu
TA贡献1786条经验 获得超11个赞
这个怎么样?
foreach($test['Topics'] as $topic)
{
echo '<option>'.$topic['TopicArn'].'</option>';
}
- 1 回答
- 0 关注
- 121 浏览
添加回答
举报
0/150
提交
取消