我目前正在使用 Amazon AWS SNS 向客戶發(fā)送 SMS。我想簡單地顯示一個下拉菜單,topicArn每個選項都作為每個選項。我從我收到的回復(fù)中嘗試了以下內(nèi)容,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>回復(fù):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條經(jīng)驗 獲得超11個贊
這個怎么樣?
foreach($test['Topics'] as $topic)
{
echo '<option>'.$topic['TopicArn'].'</option>';
}
- 1 回答
- 0 關(guān)注
- 147 瀏覽
添加回答
舉報
0/150
提交
取消