找出阵列中的特定键?

时间:2014-08-07 06:51:09

标签: php mysql

我有一个像这样的数组

[multiple_name] => Array
    (
        [0] => Change the business unit\'s root business unit
        [1] => Change the business unit\'s parent business unit
        [2] => Copy the business unit to the new position in the organizational hierarchy.
        [3] => Disable the business unit, change the business unit s organization team and then activate the business unit
    )

[multiple_correct] => Array
    (
        [1] => yes
    )

现在我想只打印此数组中的键/索引值,如'0,1,2,3'和下一个'1'。

请提前通过这个帮助我.. thanx !!

1 个答案:

答案 0 :(得分:0)

使用foreach并将键绑定到变量:

foreach($someArray as $key => $value) {
  echo $key;
}

我认为(根据您的问题)multiple_namemultiple_correct不是嵌套数组,如果它们需要foreach两次:

foreach($containerArray as $innerArray) {
  foreach($innerArray as $key => $value) {
    echo $key;
  }
}