在不知道键值的情况下迭代数组内容

Joe*_*blo 3 symfony twig

有人能告诉我如何在不知道其值的情况下迭代数组键吗?例如:

array:3 [?
  "name" => "AccountId"
  "activated" => "false"
  "type" => "string"
]
Run Code Online (Sandbox Code Playgroud)

我想得到一个选择列表:

<select name="select">
  <option>name: AccountId</option>
  <option>activated: false</option>
  <option>type: string</option>
</select>
Run Code Online (Sandbox Code Playgroud)

Mat*_*teo 5

您可以按照文档中的描述迭代键和值,例如:

<select name="select">
    {% for key, value in users %}
       < option > {{ key }}: {{ value }}</option >
    {% endfor %}
</select>
Run Code Online (Sandbox Code Playgroud)