$arr = ['night' => 'black', 'sun' => 'light', 'she' => 'gold'];
foreach ($arr as $el) {
echo ... . '<br>';
}
结果应为:
晚上
太阳
她
谢谢
答案 0 :(得分:2)
您应该使用:
<?php $array_keys = array_keys($your_array);
答案 1 :(得分:1)
您可以这样打印密钥名称:
$arr = ['night' => 'black', 'sun' => 'light', 'she' => 'gold'];
foreach ($arr as $key => $el) {
echo $key. ' <br>';
}
输出:
night
sun
she
答案 2 :(得分:0)
尝试
$key
包含您所有的数组键,$value
包含您所有的值
$arr = ['night' => 'black', 'sun' => 'light', 'she' => 'gold'];
foreach ($arr as $key=>$value) {
echo $key."=".$value."<br>";
}